My first ESP-01 "system" is running now. It measures temperature and humidity using a DHT22 every 20 seconds and send the data to an influxdb database.
The influxdb is then used by a Grafana instance where I define a panel for the temperature and humidity. Here are the first measurements:
Looks like there where a glitch at about 12:30 - I will have a look how often this happen.
And here is the corresponding ESP code:
2016-04-10
2016-04-07
First Steps with ESP-01 on OS X El Capitan - Part 2
Labels:
Electronic,
esp8266,
make,
maker,
osx
In part 1 I described how I setup my my environment. In this part I will show my first lua programming steps with the ESP8266 using the Lua based NodeMCU firmware.
First I create an init script (init.lua). This will be loaded by the firmware after each boot/restart.
As last step in the boot/restart process the firmware loads and executes the script init.lua (you can see a corresponding error message in the last screenshot in part 1).
It is recommended to provide an opportunity to interrupt the execution of init.lua to be able to change anything. Otherwise it may happen e.g. if your code contains a fatal error which cause a reboot that you are unable to deactivate/fix the code - and finally have to reflash the firmware to be break the loop.
I'm looking around an found a post about Methods of Interrupting init.lua during boot. My init.lua code based mainly on the ideas described there. But here it is:
Next step was to wrote a script to read out a DHT22 sensor. The user_dht22.lua script shown below reads temperature and humidity every 2 sec and prints both values. Depending on the used firmware the output is generated using different format and in case of integer also further values.
Output running the script
First I create an init script (init.lua). This will be loaded by the firmware after each boot/restart.
As last step in the boot/restart process the firmware loads and executes the script init.lua (you can see a corresponding error message in the last screenshot in part 1).
It is recommended to provide an opportunity to interrupt the execution of init.lua to be able to change anything. Otherwise it may happen e.g. if your code contains a fatal error which cause a reboot that you are unable to deactivate/fix the code - and finally have to reflash the firmware to be break the loop.
I'm looking around an found a post about Methods of Interrupting init.lua during boot. My init.lua code based mainly on the ideas described there. But here it is:
- it calls
firmwareInfo()
to output information about the firmware. For the moment it just inform if it is a FLOAT or INTEGER version - after a delay of
BootTimeout
ms (to give the NodeMCU some time to initialize it self)init()
is called - in
init()
the serial port is initialized and configured to watch for a transmitted ENTER key - if an ENTER is received the function
abort()
is called, which set theabortFlag
to true. - After
AbortTimeout
msstartup()
is called. There theabortFlag
is checked and the startup is canceled or executed by trying to load and execute 'user.lua'
Next step was to wrote a script to read out a DHT22 sensor. The user_dht22.lua script shown below reads temperature and humidity every 2 sec and prints both values. Depending on the used firmware the output is generated using different format and in case of integer also further values.
Output running the script
Abonnieren
Posts (Atom)