A WIFI Datalogger for Espruino PICO #968
Replies: 2 comments
-
Posted at 2018-02-19 by ClearMemory041063 Using the ringMod.js ModuleAssuming that the ringMod.js module is located in th emodules folder of the WEBide sandbox.Require the module in your code and for convience use a variable to specify the length of the rinf buffers.
Declare an array of pointers to instances of ringMOD and then create the instancesFor example:
The fields used when creating instances of ringMOD
Inserting the dataNote the logflag used to suspend logging until the clock etc are ready to log.
Logging the dataThe DHT22 returns data in a callback so call it first and in the callback save the DHT data and do the log()
The DHT temporary storage variables and the logfunct helper functions
Creating the CSV data from the data arrayThe process.memoy() commands fix a bug that the cutting edge version of Espruino has fixed. Send 10 lines at a time in the drain function to keep from using too much memory at a time.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-02-19 by ClearMemory041063 Using the PICOwifi.js ModuleRequire and create an instance of PICOwifi
Setup some variables
Create a task or a series of tasksFor example:
Setup function to start the wifi and check it periodically
The Startagain variable can be used in the task code to cause the WIFI to restart. A tasknumber could be used in Mytask to take the tasks through a series of tasks Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-02-19 by ClearMemory041063
A WIFI Datalogger for Espruino PICO
Github
What it does:
Connects to a Wifi router
Sends a Dweet containing the local IP address
Dweet
Sets the PICO RTC to the time returned by the Dweet Service
DIsconnects and reconnects to the Wifi router
Serves a Web page that allows the client to enter the filename to assign to downloaded data.
Send the collected data in comma separated format CSV with a MIME header that opens an Excel spreadsheet.
Collects the data at specified intervals and stores it in ring buffers in RAM.
The Hardware
PICO wifi shim
A pushbutton switch wired from pin B3 to ground. (Digital Read)
A 10k potentiometer or series of 10k resistors wired to vary the Voltage on pin B1 in a range of 0.0 to 3.0 Volts. (Analog Read)
(for one program) A DHT22 Relative Humidity and Temperature sensor with the power leads appropriately connected to ground and the 3.3 Volt busses and the output pin with a pullup resistor connected to PICO pin A7.
DHT22
Items to edit in order to run the examples:
In the upper right of the WebIDE is a 'gear' looking icon, hover the cursor over the icon and the word settings will appear. Click on the settings icon and then select Project. Use the "Select Directory for the Sandbox " to select or even create a sanbox directory. For example I create a sandbox named EspruinoModules. It has a number of sub-directories. We are interested in the one called \modules.
"C:\Users\jj\Documents\EspruinoModules\modules"
Copy the attached modules files to the folder:
"C:\Users\jj\Documents\EspruinoModules\modules\PICOwifi.js"
and
"C:\Users\jj\Documents\EspruinoModules\modules\ringMod.js"
"C:\Users\jj\Documents\PICOwifi\logger\Ring\Post19Feb2018\PICOwifi-Dweet-Log-Test.js"
"C:\Users\jj\Documents\PICOwifi\logger\Ring\Post19Feb2018\PICOwifi-Dweet-Log-DHT22.js"
a. ssid - wifi name
b. key - wifi password
c. DweetID make up a name unique to you
d. timezone (-6 is for CST)
The verbose refers to console output in the PICOwif module.
dsize it the length of the rung buffer used to store data.
loginterval is the number of milliseconds between data samples.
The WebIDE output:
The Dweet Page
From a browser enter the IP address
(substitute mysweet name)
https://dweet.io/get/latest/dweet/for/mydweetname
The output displayed on the web page will be
The Download Page
Using a browser enter the IP address of the PICO
For example:
http://192.168.1.11:8080/
For now just click. Later try changing the filename before clicking download. Try xxy.csv, xxx , and xx.txt.
For xxx.csv my Windows10 system displays a message at the bottom of the page that says:
The file is opened with Excel.
Example xxx.csv downloaded (see attached file):
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions