Wednesday, August 26, 2015

New progress today - ESP8266 has UNIX CRON functionality

I've added a cron functionality to my ESP8266 and is working great.
Now I can send a JSON string with unix like cron command:

{"device_name":"ESP9191919", "type":"my_isp_type", "minute":"22" , "hour":"10", "day_of_month":"26", "month":"7", "day_of_week":"3", "gpio":"14","duration":"20", "skip":"0","status":"1", "action":"add" }

to setup a cron job on a specific GPIO. I need it for my irrigation system that was using a CRON on  a raspberry PI to receive the commands for valves.

My CRON implementation support now the "*" functionality for minute, hour, day_of_month, month and day_of_week. In this version is not supporting the "*/10" functionality but if I will need it I will do it.

So sending once the JSON :

{"device_name":"ESP9191919", "type":"my_isp_type", "minute":"00" , "hour":"22", "day_of_month":"*", "month":"*", "day_of_week":"*", "gpio":"14","duration":"20", "skip":"0","status":"1", "action":"add" }

will start the valve connected to gpio 14 every day at 22:00 for 20 minutes.

If I want to skip this cron 2 days, I need to send the same JSON but with skip value of 2.

Skip value get automatically decremented and when it has the value of 0 the cron will do the job. I've need it this functionality, because finally the ESP will be an autonomous system, getting the data from Internet and from my yard, and will be able to propose me an watering plan ( in first stage to be able to test it) and finally to be able to take decisions by itself.
This is what IoT means. 

If I want to disable this cron job, I need to set the status to "0" so it will be ignored every time.

I could have also added the year as a parameter (have it but not used), but I didn't find any utility for that. But is an easy job to do it.

The important thing is that the cron data is written in the flash so a power down is not affecting the cron functionality.

Writing to flash was minimized so only if is necessary a flash update will be done. 

I've used sector 2 for storing the cron data so I can have like 400 cron jobs for now, which is enough for now. I guess I can squeeze another 1000 records in the other sectors, but for now 400 are enough.

TODO list:

Export data as JSON:
  •   {"cron_data":{"minute":"2","hour":"16",......},{"minute":"15","hour":"9",......},   {"minute":"44","hour":"12",......}, {"minute":"20","hour":"8",......}}    DONE !!!
  • */5 functionality 
  • continuity for cron jobs - if there is a power down during a cron job, continue from where it left.

Wednesday, August 12, 2015

Free book for beginers

Neil Kolban did a very good job to put all informations in one book. Reading the book is a pleasure and can introduce you in the ESP8266 world.

I would say that is mandatory for beginners to read this book.

You can download the book.

If you like it, don't forget to send an email to author.

Monday, August 3, 2015

ESP8266 conclusions after 8 month

After 8 month of working with ESP8266 I think I made an impression on this tiny wireless chip.

- It is robust ( no crashes, disconnects etc)
- can be put in low power mode ( ~100 days on three AA with reading a value a every 10 minutes and publish it on a remote server)
- the chip producer, EspressIf, is very involved in adding more features and correcting small bugs ( documentation is still on ice age, but I hope that they will makeit more clear)
- can be interconnected with various sensors
- run in non demanding conditions ( I have one module that is running in 70% humidity and 50 to 60 Celsius )

Until now I have ESP8266 modules that are connected with temperature and humidity sensors and relays. Next devices: barometric pressure, scale, IR LED. 

The modules are sending MQTT to my broker ( hosted on a PogoPlug and some time on Raspberry Pi) that is connected to my (they run a great MQTTservice) account were I have another MQTT broker. ( they are bridged). 

In this way, from my mobile application, I can control and see my modules anywhere in the word. 

If I am not at home, my application connects to my cloud broker that is connecting to my home broker where are connected my devices. In this way I can monitor and send them commands.

If I am at home my application is connecting to my local broker ( to avoid high RTD - which are not so high, something like 500 ms).

In conclusion, ESP8266EX is doing a great job, you can invest money and time in it.

Happy coding !!!