OpenSprinkler Forums Comments, Suggestions, Requests Opensprinkler on ESP8266

Tagged: ,

Viewing 25 posts - 1 through 25 (of 142 total)
  • Author
    Posts
  • #40057

    ianf
    Participant

    Ray,

    I was wondering if you’d considered using an ESP8266 instead of an ATMEGA to run the OpenSprinkler. I’ve been playing with some of the development boards (ESP-01, ESP-07 and ESP-12E) recently. They might be short of a few GPIO pins on the current hardware design, but for the cost of the ATMEGA1284, ENC28J60 and RJ45 port you can buy several ESP devices especially if you don’t buy the ESP-XX boards. They have incorporate the following:

    1. Factory MAC address.
    2. Built-in Wifi.
    3. 80MHz CPU.
    4. 80KiB RAM
    5. (external) 512KiB to 4MiB SPI FLASH, 64KiB to few MiB of that can be dedicated to SPIFFS, and if your sketch uses less than half the flash you can do OTA updates.

    There has been a lot of work recently on Arduino IDE compatibility and most of my sketches just work. The WiFi connection is also very stable and has none of the oddities that the ENC28J60 Arduino library has in it.

    One thing that has made my life so much more simple is OTA updates.

    I’m going to try building an OpenSprinker based on this chip over the next month or so.

    #40058

    tom
    Participant

    I like this idea… I’d love to see a smaller, more distributed control system… .hopefully this could fit into the Master-Slave logic eventually.

    #40084

    Ray
    Keymaster

    @ianf: a great suggestion. I have actually been experimenting with ESP8266 quite a bit a little while back and I’ve developed the ESPToy:
    http://rayshobby.net/cart/esptoy
    The pricing, Arduino IDE support, community support, and hardware capability all make it a very attractive platform. There is no immediately plan to change OpenSprinkler to use it yet, mainly because even though it looks like a better platform, it takes time to iron out all engineering issues. Instead, we are working on a different product that uses ESP8266, which will pave the way for OpenSprinkler to eventually use ESP8266. In any case, if you build an OpenSprinkler based on ESP8266, be sure to share it. I am sure many people are interested. Thanks.

    #40624

    ianf
    Participant

    I’ve just completed the first prototype (hand etched and soldered). Once I’ve ironed out the issues I’ll put up the cad files somewhere.

    Just a question. Will you be willing to include the #def stuff in the OpenSprinkler repository to enable the ESP8266 platform?

    • This reply was modified 4 years, 1 month ago by ianf.
    #40652

    Ray
    Keymaster

    Thanks for making progress on the project and sharing the picture. I think enabling ESP8266 definition in the repository requires assigning GPIO pins. I haven’t decided how to assign the pins (or even if ESP8266 has sufficient on-board pins to support all the OpenSprinkler functionality). The current list of pins are:
    – buttons: 3 digital (can be implemented with 1 analog pin and resistor divider instead)
    – shift register: 4 digital
    – LCD, RTC: I2C (can be shared with as many I2C devices as needed)
    – rain sensor and flow sensor: ideally 2 separate digital pins (1 if allowing only one sensor at a time)
    – expander sensing pin: 1 analog
    – current sensing pin: 1 analog
    – RF transmitter: 1 digital
    – sd card: SPI (if using SD card)
    So overall these are quite a number of pins. Even with the new ESP12E module, it may require a IO expander chip.

    #40671

    ianf
    Participant

    Ray,

    The ESP-12E has extra pins broken out but I believe you can’t use them without interfering with the SPI Flash interface which will affect program execution. I’ve based my prototype on the ESP-07, the only real difference between this and the ESP-12 is the ESP-07 has 1MB flash and a ceramic antenna with u.fl external antenna connector while the ESP-12 has 4MB flash and no external antenna interface. Otherwise they are interchangeable.

    For now I’m focusing on a minimal hardware implementation to prove the concept. As you can see in the picture, I’ve moved the LCD to a PCF8574 but I messed with the pin assignment to make the layout easier so I’ve a hack to the LiquidCrystal_I2C library. The second SOIC-16 footprint is for another PCF8574 to provide the additional GPIO. I considered just attaching the 74HC595 to the SPI bus (in hindsight I think it should have been done like this from the start) but I’m not sure how invasive code-wise this change would be.

    I see now that I should have connected B2 and B3 to the IO expander rather than the ESP module to free up a GPIO to use as an interrupt for state changes like buttons, and other sensors.

    The only real gotcha is the ESP8266 has one ADC channel. I guess this can be remedied by either an I2C analog mux or ADC.

    At present, I see enabling the ESP platform requiring the following:
    1. Inclusion of the LiquidCrystal_I2C library with private changes.
    2. Abstraction of the GPIO to use PCF8574/5 ICs
    3. Some pin definitions as you’ve stated.
    4. Some #ifdef magic to filter out the Ethernet library in favor of the ESP8266WIFI and cousins.
    5. Some #ifdef magic to deal with the ESP8266 flash emulated EEPROM.

    #40690

    Ray
    Keymaster

    There are actually ways to minimize the number of pins for 74HC595, by cleverly using capacitors to control signal timing:
    http://www.romanblack.com/shift1.htm

    If you use Arduino for ESP8266 (https://github.com/esp8266/Arduino), you should be able to use LiquidCrystal_I2C library directly with no modification. Also, you can buy I2C LCDs that have built-in PCF8574 so that saves one chip.

    With the shift register trick, I think it’s possible to eliminate a separate I/O expander chip. I do think it’s necessary to have an ADC chip — the PCF8591 chip I used for OSPi is probably sufficient, and there are tons of alternative ADC chips out there.

    #41634

    pbecchi
    Participant

    Hallo to everybody

    Before yesterday I discovered this trhead ,I have spent last 2 weeks triing to port Opensprinkler to ESP 8266, and I have now a version with most of the functions that compile and run……. but I need to debug it…….
    To tell you the full story, I started several months ago with the idea of automating my sprinklers unit in my garden: I have now 4 traditional programmers (raybird , irritrol and other ) located in different points in my garden and I allways run from one place to the other to program the units and check that programming time do not overlap. I started a thread on Arduino forum to get suggestions and to discuss best solutions with very little feedback. At the time I discovered the ESP8266 and I understood that was a perfect candidate for my project….. I started to write some software with the idea of a master unit that should have coordinated the other programming units.
    A month ago a discovered Opensprinkler that could have been the perfect candidate for my remote slave units and since was based on Arduinos could have been ported to ESP8266. I started downloading and modifiing a version alreay ported to Arduino Mega from Dave1001.
    After having ported release 2.0.0 last week I started with last release (much more challenging….) but thanks to previous work I succeded .
    Now I have to verify that everything works!!
    I am working on a small prototipe unit that use a ESP8266, a DS1307 compatible RCT and an I2c 4*20 LCD and a shif register IC that drive triacs. Since ESP has very few GPIO available every effort need to be done to reduce the one required to the units!
    I ready to share my work but I will appreate a little help to make it fully working and to accomplish a few modifications that I need to do…..

    Paolo

    #41667

    ianf
    Participant

    Paolo

    I’m very interested in your work – it’ll potentially save me a bunch of time porting the software. Please contact me off-line at ianf () freislich ! nom ! za and I’ll share my work. If you’re located in the USA I’ll make another board and post it you. It’s not yet ready for prime-time but I’ve attached a picture of the 3rd prototype board I made yesterday (changes are the micro SD and DS3231 RTC). I need to figure out what’s wrong with the SD interface and the soldering is rubbish because I had to de-solder and then re-solder most of the components by hand. This is the first board I made in my T-962A reflow oven and there were a bunch of shorted tracks. I’ve kept the layout single sided so I can run the boards off by hand while it still under development.

    Truth be told, I’m considering loosing the 74HC595 shift register in favour of the PCF8574 I2C PIO chip. It will fee up some pins and simplify things somewhat including expansion board detection which can just be done with an I2C scan and DIP switches to set the address of the expansion board.

    Ian

    #41683

    Ray
    Keymaster

    I have started a bit of prototyping myself. Like your design, I am using a PCF8574 to expand the number of I/Os. Regarding SD card, one technical issue I encountered is that if you use the default CS (chip select pin), that would be ESP8266’s GPIO15, but the boot sequence requires GPIO15 to be pulled low at start-up, and that contradicts with SD card requirement, which is that CS pin must be pulled up to disable SD card operation. So you will need to use a different GPIO pin as CS pin. Not sure if this is the same issue as you encountered, but just a tip.

    #41685

    pbecchi
    Participant

    Ray and Ian

    thanks for your replay!

    @Ian
    How can I contact you at…..nam!za?
    I appreciate very much your offer of one of your boards: as you can see from the pictures I am very basic in electronic prototyping:
    – first picture is a proto complete and running that use 74HC595 an RTC DS3231 , a 20*4 LCD I2C and an analog pin for buttons
    (better to foreseen this option in you breadboard)
    – second one is (not yet complete..) with PCF8574 …(having most pins free) I will go with digital buttons ( to enable double pressing)

    On both board there is no SD card …I use instead SPIFFS that emulate an SD on the ESP flash.
    This is the best I can do, as far as proto boards, hand soldering and use of stripboards. I also use existing boards as far as possible:
    for ESP8266 this an NODEMCU v1.0, for RTC this is ZS 042 with a 32k EEPROM pin .

    The way I have ported the software should maintain full backward compatibility therefore I can select different kind of hardware just using few #define
    I testing now…debugging on first propotype…… I will start soon with the second!

    @Ray

    I don’t use SD card since I want to have more GPIO available and I cannot afford to use 4 for SPI : I want to leave the pins for future development for local data acquisition (temperature, humidity and rain amount ) since local Wunder stations are not very reliable and I will use one of the stations in a glass house.
    As far as use of pin on ESP8266 (in my case NODEMCU 1.0) I made a table on attachment 3 : as you can see 3 pins are use for flashing and booting the unit (better you dont use it). Unfortunately ESP are not so well documented and the n. of pin available is very short(better to use ESP8266 v1.2+ or NODEMMCU 1.0+).
    Other point: I have preferred to use of an external I2c EEPROM rather than using ESP flash memory (could be erased) since I don’t believe there is any speed issue.

    One question: how can I modify the weather algoritm ( it is done outside the code )?
    I have seen a lot in the forum but it is only related to the Raspberry PI and is done with plug-in!

    #41689

    ianf
    Participant

    Paolo,

    Try replacing ‘()’ and ‘!’ with ‘@’ and ‘.’. I hate to have to obfuscate but the spammers have ruined it for everyone.

    Ian

    #41695

    pbecchi
    Participant

    I add the attachment with ESP8266 pinout (this is NodeMcu but the GPIO n. are the same) : you can see possible utilization of different pins!

    @for Ray:

    SD emulation on SPIFFS work well but I have some problem with wopts.txt file : it has been deleted and it doesn’t create it again.
    I dont understand his use ….. everything work without it!

    Attachments:
    #41708

    fivos
    Participant

    Hi I’m also interested in this project. If you could post your code and schematics (maybe open a github page would be easier for everyone). I could help in debug.

    #41715

    pbecchi
    Participant

    I have to complete debugging,
    but as soon as I have documented what I have done I will put the code on GitHub!
    A let you know when it will be ready!

    #41723

    fivos
    Participant

    OK, I’ll start building and help you debug as soon as you post your design.

    #41724

    pbecchi
    Participant

    For….anybody interested!

    HARDWARE for OpenSprinkler with ESP8266.

    The code is compatible for several different hardware configurations:

    MCU: ESP8266 or ARDUINO MEGA
    VALVE CONTROL: SHIFT REGISTER (like 74HC575 …. ) or I2C EXPANDER (like PCF8574)
    RTC DS1307 or DS3231 breadbords with I2C epproms (like AT24C32 )
    LCD LCD1602 or 2004 with parallel or I2C interface (or driven with a PCF8574)
    BUTTONS on ANALOG or DIGITAL Inputs Lines (or trough a PCF8574).

    So to start debugging it will be necessary to have at least one ESP8266 (better a NodeMCU v1.0 ) a RTC clock board (with EEPROM) and an LCD (better with I2c interface).
    It will be good to have or a SHIFT register chip (like 74HC575) or a PCF8574 : leds can be used for debugging ,
    later we can go with relay boards or with a simple Triac circuit.
    Remember that voltage level for ESP8266 is 3.3V and this apply to all pin (5V is no good) better to verify that I2C components are 3.3V level compatibles…..
    or to have a level shifter!

    I am preparing a Fritzing project for components connection that can be done easily on a standard breadboard.

    #41725

    fivos
    Participant

    That’s great! Can you upload the code?

    #41750

    Ray
    Keymaster

    @pbecchi: regarding storing wtopt.txt SPIFFS, it might have to do with the parameters you used when calling the SPIFFS.open function. There are a number of different options, like ‘w’, ‘r+’, ‘a’, ‘a+’. If you are reading from an existing file and modifying it, use ‘r+’; the ‘w’ parameter will cause the file to be overwritten.

    I just finished and posted my OpenGarage project:
    http://rayshobby.net/introducing-opengarage/
    if you go to the Github repository:
    https://github.com/opengarage
    you can find the code relevant to the configuration files (config.txt). The code is able to create a new file if it doesn’t exist, modify it or delete it upon factory reset.

    • This reply was modified 3 years, 8 months ago by Ray.
    #41772

    pbecchi
    Participant

    Thanks Ray for your suggestions!

    I want to inform you and everybody interested that
    you can find first beta release of OPENSPRINKLER ported to ESP8266
    on: //GitHub.com/pbecchi/OpenESP8266_Sprinkler

    Look forward to your comments and suggestions!

    • This reply was modified 3 years, 8 months ago by pbecchi.
    #41810

    Ray
    Keymaster

    Cool, very impressed with the level of details you have provided. I have bookmarked it and will check it out in a few days.

    #41825

    fivos
    Participant

    I didn’t have enough time to build the project but I was able to compile it. I had problems with (#include ../) statements. I fixed this by moving all files to the same folder and get rid of (../). Also the LiquidCrystal-I2C-library that you linked didn’t compile and I used this one https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/LiquidCrystal_V1.2.1.zip
    I will probably build the proto 2 circuit tomorrow but I couldn’t figure out where you declare the I2C addresses. It would be helpful if you can post a circuit schematic.
    Thank you for your effort, great job!

    #41828

    pbecchi
    Participant

    @fivos

    I am glad you could get already there! As I told you I need to complete documentation:

    yes , if you are using Arduino IDE you need to have all files in the same directory and to delete “../” from include statements.

    about lcd i2c library….. there is a large choise

    Declaration of all pins are in pins.h file for i2c use standard D2,D1 orchange it to your needs

    Anyhow…… today I will add documentation for compile and build and the sckematics

    #41837

    fivos
    Participant

    I’ve build the circuit lcd and opensprinkler work but it doesn’t recognize the PCF8574 so no output.This is the serial output `wire begin
    Scanning..I2C…..
    I2C device found at address 0x21 unknown
    I2C device found at address 0x27 unknown
    I2C device found at address 0x57 AT24Cxx

    @87
    I2C device found at address 0x68 DS3231

    @104
    done

    sb=0
    0D0a87<W>320D1a87<W>330D2a87<W>340D3a87<W>350D4a87<W>360D5a87<W>370D6a87<W>380D7a87<W>39<W>12//logs/10956.txt
    //logs/10957.txt
    //logs/16882.txt
    //logs/16883.txt
    /stns.dat
    b1=1
    b2=1
    b3=1
    OptSetup…
    weather.opensprinkler.com
    25
    216
    r
    0no butinit…
    clock…
    Time printed…
    Connecting…
    Setting software MAC
    Ethernet initialised
    Using http port 80
    scan start
    scan done
    Reading password file….
    [email protected]##@#@#@#@#@#@#@#@
    6 networks found
    0: home_No_internet (-46)* passw. available
    1: Pargas_Distillery_Amicos_f&bar (-75)
    2: home_No_internet (-77)* passw. available
    3: Pargas_Distillery_Amicos_f&bar (-45)
    4: 01.EpavliVeneti (-89)*
    5: Test (-66)*
    @#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@15Wait WIFI…

    Connecting to home_No_internet
    Server started IP=192.168.1.4
    Config: DHCP
    MAC: 0:69:69:2D:31:1
    Local IP: 192.168.1.4
    Gateway IP: 192.168.1.39
    DNS IP: 192.168.1.39
    Netmask: 255.255.255.0
    OptionsWrite OS:216
    216
    DHCP IP setup successful
    Ethernet setup complete
    sb=0
    0D0a87<W>320D1a87<W>330D2a87<W>340D3a87<W>350D4a87<W>360D5a87<W>370D6a87<W>380D7a87<W>39Setup complete
    -_1
    `

    #41838

    pbecchi
    Participant

    I am impressed ………………..you are really fast:

    -this is a bug in ScanI2C() already corrected : look at the new branch I have uploaded yesterday!
    -remember that as the code stand now the I2C LCD has his own library
    so his address should be given with #define LCD_ADDR 0xnn otherwise is will be considered an expander.

    Web Server works? No other bugs? Logging doesn’t work am working on it!

    Since your so fast… I will try to answer ASAP….but consider time zone (I am in Europe!)

Viewing 25 posts - 1 through 25 (of 142 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Comments, Suggestions, Requests Opensprinkler on ESP8266