Shop OBEX P1 Docs P2 Docs Learn Events
Low cost wifi module ESP8266 - Page 9 — Parallax Forums

Low cost wifi module ESP8266

1679111218

Comments

  • Cluso99Cluso99 Posts: 18,069
    Igor_Rast,
    Very interested in how you are using your own server.
    Currently I have only used ThingSpeak but have wanted to do my own thing on my server. I have a hosted site with a fixed IP address, or I can use my home which is dynamically allocated an IP address.
    What are you using and what resources on the server do you require? (PHP, etc etc)
  • Igor_Rast, thanks for sharing your code and project. We look forward to your blog and further posts.
  • Igor_RastIgor_Rast Posts: 357
    edited 2015-08-09 07:49
    Cluso99 wrote: »
    Igor_Rast,
    Very interested in how you are using your own server.
    Currently I have only used ThingSpeak but have wanted to do my own thing on my server. I have a hosted site with a fixed IP address, or I can use my home which is dynamically allocated an IP address.
    What are you using and what resources on the server do you require? (PHP, etc etc)

    Your guys are welcome,
    Cause my Main PC (ubuntu 12.04)is never shuts down, im running a local LAMP server on it. and using that to log the data to it.(and local develpment )
    Esentialy I use Apache2 configed as a named based server wich serves the php page(so php is also needed), mysql as the database and phpmyadmin as an interface to look at the data(for now)
    the main pc does have a static ip, but the esp just gets his ip with dhcp.
    its not that fancy of an setup, so I expect its possible to run the php page on a raspberry pi if you wanted a standalone solution too(maybe something ill try in the future)

    @macrobeak, ill try to make the blog post in the comming week with some more explination of the setup, and some schematics on how I wired it all together.
    (fingers crossed I manage that this week :p)

    now that I thouth about it, One thing to note in my coding is . I expect the hdcp lease time will eventualy expire. so ill have to do something about that .
    do a dhcp release every 6 hours orso to keep another device from taking that ip the esp has.
  • @Igor_Rast

    Thanks a bunch, could I see the LUA side of things? Or a snippet of the serial comm side pls?

    Thank you.
  • Igor_RastIgor_Rast Posts: 357
    edited 2015-08-10 15:02
    xanadu wrote: »
    @Igor_Rast

    Thanks a bunch, could I see the LUA side of things? Or a snippet of the serial comm side pls?

    Thank you.

    Lua side of thigs.
    flashed the esp using the propplug and esptool

    plug Rx -> esp tx
    plugTx->esp rx
    plug VSS -> esp gnd

    esp GPIO 0 pulled low.


    "git clone https://github.com/themadinventor/esptool.git"
    "cd /home/$USER/esptool"

    find latest firmware (nodemcu_latest.bin) and put in the esptool folder
    then run
    "python esptool.py --port /dev/ttyUSB0 write_flash 0x00000 nodemcu_latest.bin"

    use the attached firmware or your own.
    all succesfull flashing ? , then go ahead and connect it back to your propeller.
    pull the 2 GPIOs and CH_PD up for normal operation.

    that should be it.
    Terminal output
    Booting system
    Start ESP connection
    Making sure ABC function is disabled in all K30 sensors
    Connect to Wifi
    node.restart()
    >

    9))

    NodeMCU 0.9.5 build 20150214 powered by Lua 5.1.4
    lua: cannot open init.lua
    > wifi.setmode(wifi.STATION)
    > wifi.sta.config("SSID","PASSWORD")
    > wifi.sta.connect()
    > print(wifi.sta.getip())
    192.168.2.10 255.255.255.0 192.168.2.254
    > setting up clock and then do my job
    conn=net.createConnection(net.TCP, 0)
    > conn:on("receive", function(conn, payload) print(payload) end)
    > conn:connect(80,"192.168.2.50")
    > conn:send("GET /index2.php?sensor1=783&sensor2=815&sensor3=927&sensor4=929&sensor5=
    1017&sensor6=941&sensor7=1170&temp=290&lv=39 HTTP/1.1\r\n")conn:send("Host: boekhoudi
    ng.dev\r\n")
    > conn:send("Accept: */*\r\n")
    > conn:send("\r\n")
    > HTTP/1.1 200 OK
    Date: Mon, 10 Aug 2015 14:55:30 GMT
    Server: Apache/2.4.7 (Ubuntu)
    X-Powered-By: PHP/5.5.9-1ubuntu4.11
    Content-Length: 3
    Content-Type: text/html




    conn:close()
    > conn=net.createConnection(net.TCP, 0)
    > conn:on("receive", function(conn, payload) print(payload) end)
    > conn:connect(80,"192.168.2.50")
    > conn:send("GET /index2.php?sensor1=625&sensor2=593&sensor3=664&sensor4=640&sensor5=
    687&sensor6=626&sensor7=825&temp=297&lv=37 HTTP/1.1\r\n")conn:send("Host: boekhouding
    .dev\r\n")
    > conn:send("Accept: */*\r\n")
    > conn:send("\r\n")
    > HTTP/1.1 200 OK
    Date: Mon, 10 Aug 2015 14:57:30 GMT
    Server: Apache/2.4.7 (Ubuntu)
    X-Powered-By: PHP/5.5.9-1ubuntu4.11
    Content-Length: 3
    Content-Type: text/html

    the last part is the repeating one that happens at an interval of 60 seconds

    Hope it helps.

    I.C.E.C
  • Okay, I was imagining connecting the GPIO to the Propeller, and putting serial code into init.lua. Are you connecting the Propeller directly to the ESP tx/rx lines and sending it commands via serial?

    Do you have anything in init.lua at all?

    Thanks.

  • MJBMJB Posts: 1,235
    edited 2015-08-11 01:29
    xanadu wrote: »
    Okay, I was imagining connecting the GPIO to the Propeller, and putting serial code into init.lua. Are you connecting the Propeller directly to the ESP tx/rx lines and sending it commands via serial?

    Do you have anything in init.lua at all?

    Thanks.

    have a look at my link to the TACHYON thread above
    there you see what could be put into init.lua to handle serial requests to send data to thingspeak.com

    I keep my prop RxTx connected to the interactive terminal.
    And use a seperate IO to send commands to ESP Rx
  • MJB wrote: »
    xanadu wrote: »
    Okay, I was imagining connecting the GPIO to the Propeller, and putting serial code into init.lua. Are you connecting the Propeller directly to the ESP tx/rx lines and sending it commands via serial?

    Do you have anything in init.lua at all?

    Thanks.

    have a look at my link to the TACHYON thread above
    there you see what could be put into init.lua to handle serial requests to send data to thingspeak.com

    I keep my prop RxTx connected to the interactive terminal.
    And use a seperate IO to send commands to ESP Rx

    I did, I've looked over your LUA and do not see anything about accepting serial connections. Does the ESP automatically take serial commands over the tx/rx ports once it boots, while the LUA is running?

    I have LUA running and uploading to thingspeak. I haven't tried sending the ESP serial commands on the tx/rx line while this is happening. Is that all there is to it?

  • Sorry for over complicating this haha. I have it sorted out now. I actually have sent the ESP serial commands while init.lua was running. I just need to connect the tx/rx to the Prop instead of the computer. I was imagining all three going at once.

    Thanks for the help!
  • Cluso99Cluso99 Posts: 18,069
    Lua always accepts commands over the serial line (ie it uses the serial I/O for a terminal to be attached).
    So the prop will act as a terminal.
  • xanaduxanadu Posts: 3,347
    edited 2015-08-11 02:38
    Thanks Cluso99, that is where I was hung up.

    Kind of silly, considering it would be bricked otherwise!
  • xanadu wrote: »
    Thanks Cluso99, that is where I was hung up.

    Kind of silly, considering it would be bricked otherwise!

    Seems you figured it out :p

  • Igor_Rast wrote: »
    xanadu wrote: »
    Thanks Cluso99, that is where I was hung up.

    Kind of silly, considering it would be bricked otherwise!

    Seems you figured it out :p

    100%

    We have lift off. I connected my ESP to the Propeller. Originally I had done this with AT mode. Now I see that running the ESP side on node and using the Propeller to communicate via tx/rx is much better. It isn't because the ESP is connected via serial to the Prop, as it already was in AT mode. The difference is by time the Propeller is running the ESP is too, and it is already connected to the network :)



  • MJBMJB Posts: 1,235
    xanadu wrote: »
    Sorry for over complicating this haha. I have it sorted out now. I actually have sent the ESP serial commands while init.lua was running. I just need to connect the tx/rx to the Prop instead of the computer. I was imagining all three going at once.

    Thanks for the help!

    actually I set it up so the ESP output goes to the PC/Terminal as well so I can see what is going on.

    And I have an other Teraterm running
    with the TACHYON prompt so can work interactively with the PROP.
    And from Tachyon/Prop to ESP I use a seperate bit banged serial connection.

    This is a fantastically easy way to work with it.

  • Right on, you can have all three at once, bad choice of words on my part. I finally do, too. Having two MCUs connected doing their various functions, plus keeping an eye on each other is a lot of fun!
  • Some more experiments with the ESP8266 - now have it talking to bulletin boards and (almost) doing FTP transfers. Also have it uploading and downloading with xively.
    Attached is some code - this is written in C and in a very old dialect from the 1980s. It is running on CP/M on a Z80 emulation on a FPGA.
    However the principles should be transportable to the Propeller as everything is just talking serial at 9600 baud.
    The key to sending data to the internet is to wrap it up in a package with the number of bytes in the package. The key to receiving data from the internet such as a BBS is to use the same package format. The BBS and FTP etc send back data with a format +IPD,0,nnn: where nnn is the number of bytes to follow. So if you strip off this header, the display comes through as expected.
    All great fun!
    800 x 600 - 101K
    800 x 600 - 137K
  • More crazy things. Uploading data to xively every few minutes. Xively lets you show graphs but you have to log into the account each time. So... followed this tutorial https://personal.xively.com/dev/tutorials/channel-viz/

    and created a web page over on github. Then modified a few lines of java code (eg to scale the graph differently), and it now appears as a website publicly available to everyone

    http://moxhamj.github.io/channel-viz/

    Some thoughts re the AT commands - initially I wrote code to look for responses like "OK" but the responses are not quite the same each time - eg messages like "link is not...". So now I have some simpler code which has time delays and just scans the characters and dumps them to the screen as they come back. Eventually the esp module seems to time out- maybe 10 seconds at the very most. The longest delays are joining a router, and linking to a website. It greatly helps the debugging process to print everything to a screen - the data going out, data coming back etc.

    For CP/M the display is an 80x25 monitor. On a propeller there are various terminal objects available for both TV and VGA. Pick one that has a decent number of characters (debugging on a little 20x4 LCD was a bit painful!).
  • NWCCTVNWCCTV Posts: 3,629
    edited 2016-06-03 20:16
    I know this is an old thread but i have several of the ESP8266 modules and I would like to put them to use. Does anyone by chance have a schematic as to how to connect to a Propeller and SPIN or C code examples? I know Propeller Powered use to have something but I am unable to locate. Thanks for the help.
  • Andy, this post from earlier in the thread has connection info for an ESP-01 (that's the one with 2x4 pins at the one end). A few posts before that is a picture of the ESP-01.

    Scattered around that timeframe in the thread are some examples of code, I believe.

    A lot of people are reloading the ESP with Lua or now, MicroPython (except for the ESP-01) and just talking serial to a Lua or Python program running on the ESP instead of using the AT commands. It offloads work from the PRopeller and Lua and MicroPython handle the network stuff much better than Spin with the AT commands.

    The ESP-01s are kind of the runt of the litter. The 12f are probably the best of breed for general use now. Memory is up to 4M and the radios and antennas seem to be better.
  • Thanks. I started reading from page 1 and see now how to connect. I am pretty sure I have the 01version as I bought them shortly after this thread was started. I have several and would like to get some use from them before buying anymore.What exactly is Lua?
  • Lua on ESP-01/-02/-201 (with 512k flash) definitely is possible.

    You'll only have round about 64k for files but for some glue code between the net and your Propeller, this probably is enough...
    > =file.fsinfo()
    64256   3765    68021
    > require "ll"()
         61 init.lua
        133 cat.lua
        592 telnetd.lua
        421 thingspeak.lua
        176 ll.lua
        101 init-sta.lua
    > _
    

    MicroPython will run with this small flash size too but I have no experiences how usefull it will be without it's flash filesystem:
    The internal filesystem

    If your devices has 1Mbyte or more of storage then it will be set up (upon first boot) to contain a filesystem. This filesystem uses the FAT format and is stored in the flash after the MicroPython firmware.
  • yeti wrote: »
    Lua on ESP-01/-02/-201 (with 512k flash) definitely is possible.

    You'll only have round about 64k for files but for some glue code between the net and your Propeller, this probably is enough...
    > =file.fsinfo()
    64256   3765    68021
    > require "ll"()
         61 init.lua
        133 cat.lua
        592 telnetd.lua
        421 thingspeak.lua
        176 ll.lua
        101 init-sta.lua
    > _
    

    MicroPython will run with this small flash size too but I have no experiences how usefull it will be without it's flash filesystem:
    The internal filesystem

    If your devices has 1Mbyte or more of storage then it will be set up (upon first boot) to contain a filesystem. This filesystem uses the FAT format and is stored in the flash after the MicroPython firmware.
    Can you give some examples of the type of glue you're using between the Propeller and the net?

  • Heater.Heater. Posts: 21,230
    Lua is an interpreted programming language. Looks a bit like C, syntax wise. Kind of like Javascript. Very easy to learn and use. Very nice.

    This is Lua:
    -- defines a factorial function
    function fact (n)
      if n == 0 then
        return 1
      else
        return n * fact(n-1)
      end
    end
        
    print("enter a number:")
    a = io.read("*number")        -- read a number
    print(fact(a))
    
  • So I could essentially connect the 8266 to a Spinneret to create a wireless web server, correct?
  • Heater.Heater. Posts: 21,230
    Why would you need the Spinneret?
  • you do not even need a propeller-chip to create a webserver with the ESP8266-modul.
    it's not only Wifi-hardware it's a microcontroller-system for itself. Somehow it is a bit sad but the ESP8266-moduls are some kind of a disruptor to Arduinos, Propeller-chips etc.

    If your project just needs some LEDs, buttons, a onewire-sensor or controlling 2 or 3 servos
    you can do it with a $5-ESP8266 modul stand-alone and even have WiFi-connectivity.

    best regards

    Stefan
  • Heater. wrote: »
    Lua is an interpreted programming language. Looks a bit like C, syntax wise. Kind of like Javascript. Very easy to learn and use. Very nice.

    This is Lua:
    -- defines a factorial function
    function fact (n)
      if n == 0 then
        return 1
      else
        return n * fact(n-1)
      end
    end
        
    print("enter a number:")
    a = io.read("*number")        -- read a number
    print(fact(a))
    
    Sorry, I guess I wasn't clear. I know what the Lua language looks like. I was looking for an example of code acting as a bridge between a Propeller and the network. I'm just wondering how people use the ESP with Lua (NodeMCU) with the Propeller.

  • Thanks for the input. Quick question. Are the ESP8266 similar to the Serial WIFI adapters Jeff (OBC) use to sell? http://propellerpowered.com/forum/index.php?topic=230.0
  • xanaduxanadu Posts: 3,347
    edited 2016-06-04 00:53
    Page 8 and 9 contain two different ways to connect the ESP to the Propeller. I used Igor_rast's (starting on pg 8 ) and it worked great.

    I'm not sure about Jeff's serial wifi adapters, but the ESP can become a transparent serial bridge in just a few steps. I lost the links to the tutorials I followed, there are many out there and should be easy to find.

    All of this is after you flash NodeMCU on the ESP, that would probably be the first step. There is a lot you can do with AT mode, but NodeMCU seemed a lot easier to work with.
Sign In or Register to comment.