The datetime (softRTC) update application below, works as expected. So, all you need is an internet access that keeps your desktop computer clock up to date, and you should be able to have the correct date and time on your Propeller board applications.
Now I will try to implement this to my solar windowsill project, and start to think about some data logging with real times and dates. This is easier said then done proposal, but if you keep jabbing at it, it will submit to your will.
<!-- dt_update.html -->
<!DOCTYPE html>
<html>
<body>
<H2>System Time and Date from Microcontroller</H2>
<p>Click Date to see system Date from Micro:</p>
<button onclick="getFromMcu('Dates')">Date</button>
<p id="valueD">Waiting...</p>
<p>Click Time to see system Time from Micro:</p>
<button onclick="getFromMcu('Times')">Time</button>
<p id="valueT">Waiting...</p>
<H3>Update System Time and Date on Microcontroller</H3>
<p>Click Date to update system Date</p>
<button onclick="dateBtn()">Date</button>
<p>Date splash screen</p>
<p id = "dateTxt">Waiting...</p>
<p>Click Time to update system Time</p>
<button onclick="timeBtn()">Time</button>
<p>Time splash screen</p>
<p id = "timeTxt">Waiting...</p>
<script>
var getPathExt;
function useMcuReply(response)
{
if(getPathExt == 'Dates')
{
var val = document.getElementById("valueD");
val.innerHTML = "ValueD: " + response;
}
else if(getPathExt == 'Times')
{
var val = document.getElementById("valueT");
val.innerHTML = "ValueT: " + response;
}
}
function dateBtn()
{
var dt = new Date();
day = dt.getDate();
var dt1 = new Date();
month = dt1.getMonth();
month = month + 1;
var dt2 = new Date();
year = dt2.getFullYear();
var send = "month=" + month + "day=" + day + "year=" + year;
httpPost("/tpfm/date",send);
document.getElementById("dateTxt").innerHTML = "To micro: "
+ month + "/"+ day + "/" + year;
}
function getFromMcu(pathExt)
{
getPathExt = pathExt;
httpGet("/tpfm/" + pathExt, useMcuReply);
}
function httpGet(path, callback)
{
var req = new XMLHttpRequest();
req.open("GET", path, true);
req.onreadystatechange = function()
{
if (req.readyState == 4)
if(req.status == 200)
callback(req.responseText);
else
callback("Waiting...");
}
req.send(null);
}
function httpPost(path,param)
{
var req = new XMLHttpRequest();
req.open("POST", path, true);
req.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
req.send(param);
}
function timeBtn()
{
var dt = new Date();
var hours = dt.getHours();
var dt1 = new Date();
var minutes = dt1.getMinutes();
var dt2 = new Date();
var seconds = dt2.getSeconds();
var send = "hour=" + hours + "minutes=" + minutes +
"seconds=" + seconds;
httpPost("/tpfm/time",send);
document.getElementById("timeTxt").innerHTML = "To micro: "
+ hours + ":"+ minutes + ":" + seconds;
}
</script>
</body>
</html>
Just an update, I applied the sRTC (dt_update) to my solar windowsill project, which runs 24/7, and the sRTC keeps very good time. It also makes it very convenient for keeping the sRTC updated after a reboot.
In another thread there was mention of a FLIP module that will be available soon. I wonder if WX WiFi SIP module will be a plug and play with the FLIP module?
I can see an interesting application using the FLIP+WX WiFi and the Telnet. Sometimes I like to have a command line UI instead of a GUI (browser) approach.
Ray, thanks for following through with your project and posting this code here. I've been trying to get the web page to send the date and time to my project but I kept hitting road blocks. You code looks easy to follow and I think it's just what I need.
I have been away for a few months, decided to do some programming again. Below is code for a very simple program using the Parallax Activity WX board and an html browser program. Next, I will try to add a digital clock to the html, and maybe have it update the rtc code on the Activity board.
So far it is a good start. If anybody wants to join in, feel free to upgrade the code below.
Any chance that Parallax will be adding P2 to the SimpleIDE program?
I just installed SimpleIDE for Linux and seems that it is not locating my Activity WX board, wifi of course. Am I missing something during the installation?
To find the WiFi board it sends out a broadcast UDP packet which the WiFi board sees and responds back to the IP address that sent it. If the WiFi board is not on the same network it will not find it.
The P2 will not be supported with SimpleIDE. I have switched to FlexProp which works just fine. Some small changes are required to make P1 code work on the P2 with FlexProp.
It kind looks like Parallax will not be doing anything more with SimpleIDE, let alone installing the P2. I am now using the P1 more, so I like SimpleIDE because it has most of the drivers for all their little devices.
I like flexprop, but you have to create all the device drivers, for C. I do not do drivers, sometimes I have a heck of a time just trying to program in C.
That's a really good point there Ray.
I wonder if there's an existing way (or set of instructions) on how to leverage all those SimpleIDE libraries in FlexProp?
It feels like there could be. Maybe @ersmith would know ?
Some time ago I looked at the SimpleIDE libraries, and it looks like all of the code is interdependent. Not sure if you could just take one lib and have it work in flexprop.
All the library functions are compiled into a library object matching the library type. Also the library code is there as well so you can modify it if you like and then build a new library from it.
I have several libraries that I have built for the P1 and also converted most of them for use with FlexProp on the P2.
At this point there is no home for sharing C library code.
SimpleIDE is still my choice for building program on the P1. I only use FlexProp for the P2.
@VonSzarvas said:
That's a really good point there Ray.
I wonder if there's an existing way (or set of instructions) on how to leverage all those SimpleIDE libraries in FlexProp?
It feels like there could be. Maybe @ersmith would know ?
@"Roy Eltham" ported a number of the simple libraries to FlexProp, and those are in the standard FlexProp distribution. Some examples are in samples/simpletools.
@Rsadeika if you have specific drivers you're interested in you should start a thread about them, perhaps someone else will also be interested and want to work with you to port them.
Alternatively, you can almost always use Spin2 drivers from FlexC, and there are a variety of those already existing for the P2.
A couple of things, concerning the use of FlexC as an alternative to SimpleIDE. SimpleIDE has wifi.h and some code for using the ADC. Not sure how many forum members are making use of P1/WEB page posibilities, but I am starting to use that more and more for some of my projects.
I noticed, in another thread, that jroark made some significant progress with the bmp680. That would be an interesting project, have the information displayed on a WEB page for all of your devices using FlexProp. Just a few things that I am thinking about.
I love SimpleIDE and P1. And I'm disappointed that SimpleIDE won't be upgraded to support the P2. I'm exploring Catalina for P2 C programming, but in the mean time, P1 it is!
I like using the Activity Board WX with HTML, JavaScript and I've just started exploring APIs and Postman. So much power! So many possibilities!
I just discovered the Circuit Overlay Board (p/n 32999). I think these will help make my experiments more permanent.
Currently I'm building a garden monitoring station (multiple moisture meters, temperature, humidity, data-logging, and eventually including weather forecasting and a drip system.)
HTML / JavaSript / APIs add so much more to a real world P1 project, it may be a long time before I need a P2.
Below is a test program to see if the digital clock and the buttons all work. I grabbed some html code that runs a digital clock, the only problem is that it always shows the 'PM'. Could not figure out how to make it switch between AM and PM.
Because the digital clock runs constantly, I wanted to make sure that the buttons would work also. It seems that javascript has a tasking feature, I think, not sure how many separate tasks it could run.
I was considering adding an RTC module to the Activity board, but since it is possible to set a two-way conversation between the html and the propeller, I could just use the html clock code. Now I have to double check to see how much memory the WiFi module has, I can see the html program growing in size, very quickly.
Not sure why the Learn site is not devoting more time to show more examples for using the html stuff.
Comments
Now I will try to implement this to my solar windowsill project, and start to think about some data logging with real times and dates. This is easier said then done proposal, but if you keep jabbing at it, it will submit to your will.
Ray
In another thread there was mention of a FLIP module that will be available soon. I wonder if WX WiFi SIP module will be a plug and play with the FLIP module?
I can see an interesting application using the FLIP+WX WiFi and the Telnet. Sometimes I like to have a command line UI instead of a GUI (browser) approach.
Ray
Ray, thanks for following through with your project and posting this code here. I've been trying to get the web page to send the date and time to my project but I kept hitting road blocks. You code looks easy to follow and I think it's just what I need.
Thanks again.
I have been away for a few months, decided to do some programming again. Below is code for a very simple program using the Parallax Activity WX board and an html browser program. Next, I will try to add a digital clock to the html, and maybe have it update the rtc code on the Activity board.
So far it is a good start. If anybody wants to join in, feel free to upgrade the code below.
Any chance that Parallax will be adding P2 to the SimpleIDE program?
Ray
The html code.
I just installed SimpleIDE for Linux and seems that it is not locating my Activity WX board, wifi of course. Am I missing something during the installation?
Ray
To find the WiFi board it sends out a broadcast UDP packet which the WiFi board sees and responds back to the IP address that sent it. If the WiFi board is not on the same network it will not find it.
The P2 will not be supported with SimpleIDE. I have switched to FlexProp which works just fine. Some small changes are required to make P1 code work on the P2 with FlexProp.
Mike
It kind looks like Parallax will not be doing anything more with SimpleIDE, let alone installing the P2. I am now using the P1 more, so I like SimpleIDE because it has most of the drivers for all their little devices.
I like flexprop, but you have to create all the device drivers, for C. I do not do drivers, sometimes I have a heck of a time just trying to program in C.
Ray
That's a really good point there Ray.
I wonder if there's an existing way (or set of instructions) on how to leverage all those SimpleIDE libraries in FlexProp?
It feels like there could be. Maybe @ersmith would know ?
Some time ago I looked at the SimpleIDE libraries, and it looks like all of the code is interdependent. Not sure if you could just take one lib and have it work in flexprop.
Ray
All the library functions are compiled into a library object matching the library type. Also the library code is there as well so you can modify it if you like and then build a new library from it.
I have several libraries that I have built for the P1 and also converted most of them for use with FlexProp on the P2.
At this point there is no home for sharing C library code.
SimpleIDE is still my choice for building program on the P1. I only use FlexProp for the P2.
Here are my libraries for the P1: Custom P1 Libraries
Here are my libraries for the P2 that work with FlexProp: P2 Custom Libraries
Mike
@"Roy Eltham" ported a number of the simple libraries to FlexProp, and those are in the standard FlexProp distribution. Some examples are in samples/simpletools.
@Rsadeika if you have specific drivers you're interested in you should start a thread about them, perhaps someone else will also be interested and want to work with you to port them.
Alternatively, you can almost always use Spin2 drivers from FlexC, and there are a variety of those already existing for the P2.
A couple of things, concerning the use of FlexC as an alternative to SimpleIDE. SimpleIDE has wifi.h and some code for using the ADC. Not sure how many forum members are making use of P1/WEB page posibilities, but I am starting to use that more and more for some of my projects.
I noticed, in another thread, that jroark made some significant progress with the bmp680. That would be an interesting project, have the information displayed on a WEB page for all of your devices using FlexProp. Just a few things that I am thinking about.
Ray
Something like this page? Home Weather Station
This is using a WiFi module to send weather information to a web server.
BME280, AS5048A, Magnetic switches.
Mike
I love SimpleIDE and P1. And I'm disappointed that SimpleIDE won't be upgraded to support the P2. I'm exploring Catalina for P2 C programming, but in the mean time, P1 it is!
I like using the Activity Board WX with HTML, JavaScript and I've just started exploring APIs and Postman. So much power! So many possibilities!
I just discovered the Circuit Overlay Board (p/n 32999). I think these will help make my experiments more permanent.
Currently I'm building a garden monitoring station (multiple moisture meters, temperature, humidity, data-logging, and eventually including weather forecasting and a drip system.)
HTML / JavaSript / APIs add so much more to a real world P1 project, it may be a long time before I need a P2.
@TommieBoy ,
I do a lot of Plug and Play. It simplifies moving from prop to prop and building things.
Mike
Below is a test program to see if the digital clock and the buttons all work. I grabbed some html code that runs a digital clock, the only problem is that it always shows the 'PM'. Could not figure out how to make it switch between AM and PM.
Because the digital clock runs constantly, I wanted to make sure that the buttons would work also. It seems that javascript has a tasking feature, I think, not sure how many separate tasks it could run.
I was considering adding an RTC module to the Activity board, but since it is possible to set a two-way conversation between the html and the propeller, I could just use the html clock code. Now I have to double check to see how much memory the WiFi module has, I can see the html program growing in size, very quickly.
Not sure why the Learn site is not devoting more time to show more examples for using the html stuff.
Ray
html code