Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : wifi display project.
Page 1 of 2 | |||||
Author | Message | ||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
Wheee.... finally got my maximite driving a esp8266 module to act as a tcpip server and drive an i2c based display as well. I can now send a tcpip packet with the digits to display. once I've got the code a little bit tidier I'll transfer it to a micromite and make a much more compact unit. eventually I have a big matrix display to get working for tweets and the like |
||||
viscomjim Guru Joined: 08/01/2014 Location: United StatesPosts: 925 |
Hi Carl, nice job there! Is the display the I2C one from adafruit? Would love to see your code for the esp8266. Are you finding that it is stable and do you know what firmware version it is running (the firmware on the esp8266)? |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
Yes, it's the adafruit display. I've also got the red,green,orange 8x8 display working. It uses the same driver chip. As for the ESP, I had to go to the 3rd party firmware which allows the baud rate to be changed as the maximite can't do the higher speeds. I'll post the code later on when I'm at my main pc |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
here's the code (such that it is) The wifi stuff is towards the bottom. Its really pretty easy with these modules, I found that parsing out the data is the hardest bit. The firmware I'm using is this one which lets you alter the baud rate. http://www.electrodragon.com/w/ESP8266_Firmware port = &h70 Sub startup 'open I2c and start the display I2C open 200, 100 I2C write port, 0, 3, &H21, &HA0, &H83 End Sub Sub shutdown 'close i2c I2C close End Sub 'Print "start" 'startup 'clear '00000001 = bottom '00001000 = top '01000000 = center '00010000 = rt '00100000 = rb '00000100 = lt '00000010 = lb dim digits(16) digits(0)=&B10111111 digits(1)=&B00110000 digits(2)=&B01011011 digits(3)=&B01111001 digits(4)=&B01110100 digits(5)=&B01101101 digits(6)=&B01101111 digits(7)=&B00111000 digits(8)=&B01111111 digits(9)=&B01111100 digits(10)=&B01111110 digits(11)=&B01100111 digits(12)=&B01000011 digits(13)=&B01110011 digits(14)=&B11001111 digits(15)=&B01001110 Sub printValue(val) ' print a 4 digit number digit1 = val \ 1000 digit2 = val Mod 1000 \ 100 digit3 = val Mod 100 \ 10 digit4 = val Mod 10 a = digits(digit4) b = digits(digit3) c = digits(digit2) d = digits(digit1) I2C write port, 1, 9, &H00, a, 0, b, 0, 0, 0, c,0 I2C write port, 1, 9, &H08, d,0,0,0,0,0,0,0 I2C write port, 0, 1, &H81 End Sub Sub sendAndReceive(cmd$, result$) ' send command to esp8266 and wait for the result Print cmd$ Print #1, cmd$ prevChrs = 0 chrs = 0 Do Pause 400 Print "."; prevChrs = chrs chrs = Loc(#1) Loop While chrs<>prevChrs Or chrs=0 result$=Input$(chrs,#1) Print result$ End Sub Sub receive(result$) ' get data (if any) from the esp8266 If Loc(#1) <> 0 Then prevChrs = 0 chrs = 0 Do Pause 400 prevChrs = chrs chrs = Loc(#1) Loop While chrs<>prevChrs Or chrs=0 result$=Input$(chrs,#1) Print result$ EndIf End Sub ssid$="C.I.A." pw$="yourpasswordhere" q$=Chr$(34) startup Open "com1:9600" As #1 sendAndReceive("ATE0", answer$) sendAndReceive("AT", answer$) join$="AT+CWJAP="+q$+ssid$+q$+","+q$+pw$+q$ sendAndReceive(join$, answer$) sendAndReceive("AT+CIFSR", answer$) sendAndReceive("AT+CIPMUX=1", answer$) sendAndReceive("AT+CIPSERVER=1,9000") sendAndReceive("AT+CIPSTO=120", answer$) sendAndReceive("AT+CIFSR", answer$) ' main loop. look for messages from wifi, parse and display do answer$ = "" receive(answer$) sizePos = instr(1, answer$, "+IPD,0,") If sizePos <> 0 Then answer$=Mid$(answer$, sizePos+7) If answer$ <> "" Then colonPos = instr(1, answer$, ":") msgLen=Val(Mid$(answer$,1,colonPos-1)) msg$=Mid$(answer$,colonPos+1,msgLen) print msg$ printValue(Val(msg$)) EndIf EndIf loop while msg$<>"0000" print "Closing" close #1 shutdown |
||||
viscomjim Guru Joined: 08/01/2014 Location: United StatesPosts: 925 |
Hi Carl, do you ever get the "busy s" error from the esp8266 when you are sending or receiving data? What does a typical message that you send to the unit look like? Sorry for all the questions. |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1328 |
Nicely done Carl, I'm going to have to give my ESP8266 another go when I get a bit more time. I found the firmware I was using several months ago (from ElectroDragon) pretty flaky but John (Jman in NZ) seemed to have better luck. Your link seems to look different so it's probably been updated. Greg |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
I've not done any robustness testing but I have seen the occasional message that didn't show. I want to convert from tcpip to udp so the handshake is simpler. after that I'll write something to give it a good hammering (probably tonight) the message you get when you fling a tcpip packet at it is like this 0,CONNECT
+IPD,0,3:1240,CLOSED the 3:124 bit is the data. 3 ascii bytes 123. I just parse out the data and trust I'm getting 1-4 decimal digits at this point. At this point i'm just using "Packet Sender" by DanNagle.com for driving. |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
with AT+GMR i get this response AT version:0.21.0.0 SDK version:0.9.5 |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
so after some tinkering I've got a reliable result apparently you can't set up a server for udp with the current AT commands.. I put together some client code that opened the port and sent numbers 0000 to 9999. without a delay in the client between messages i missed a lot of results and eventually crashed the esp8266. by raising the baud rate to 19200, and limiting myself to 1 call per second I've got a reliable count-up on the hardware. before this I was occasionally getting some messages run together. eg. i was sending 1234 1235 1236 as individual messages and getting 123412351236 at the micromite. so for reliable messaging, you'd need to have a protocol that either prefixed with the length or bounded each end of the message with a unique character. |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
so I adjusted my protocol to have [] around each number. This had the desired effect of not having messages run together when there was a pile-up in the queue, which seemed to happen every now and then. I set up a server to open the port and send numbers 1-9999 to the display. It seems to get to about 1700 before the ESP2866 crashes. I get a bunch of "connection failed" messages and then what looks like a reset of some sort on the esp. is this the problem you hit, viscomjim? |
||||
viscomjim Guru Joined: 08/01/2014 Location: United StatesPosts: 925 |
Hi Carl, I had been using the esp8266 for a while and tried all sorts of things to get a reliable steady working unit going using the uMite. Even after some of the newer updates, I still had some issues with this unit. I don't know if you saw the project Geoff did using the esp8266 that was in silicon chip magazine, I think it was Nov. but not exactly sure. It seems like it is best to be able to allow the uMite to have control of the esp's power in order to do a full power cycle reset after the esp hangs. I had pretty much given up on using the esp with the AT command set except for simple things like sending slow data to thingspeek, which is kind of cool. I haven't had the time to look into the new firmware available like lua, node ncu and now the arduino ide can be used from what I have read. I really want this thing to work as it would be great to be able to reliably put a uMite on the network, but so far no go. One more thing... I have been able to set up the unit to send an email to my godaddy imap email account. That seemed to work pretty good but still crashed every once in a while. Check this thread HERE and HERE for some more info. If you keep on working on this, please give us some updates. I would love to try this again if you find some success with the new firmware that you have. EDIT... I see that http://garden.geoffg.net/ is still up and running. That is a good thing... |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
so I've got a client set up to connect with tcpip and send numbers 1-9999 (1 every 400ms). It was getting to around 1200-1400 or so and then having the esp crash. i found a thread that suggested the reset was a power problem, so I added a big cap across the ESP power supply. its currently at 6793 and counting... |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
and after a bit of testing its only a partial success. the esp8266 stays stable for much longer but still eventually fails. Time to assign it to background processing for a while and see if inspiration strikes |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1328 |
Let us all know if you do get it going reliably Carl - it would be a great addition. Greg |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8592 |
I use this module Rock solid reliable. The set-up can be done by AT commands but much easier by its own web GUI, all settings are then saved in non-volatile memory. I have had three running monitoring various bits and pieces for over two years and they have never missed a beat. The only gotcha is that the power supply needs to handle the current surge on wireless transmission so good decoupling and power reservoir capacitors are essential. See this post for example code |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1328 |
I missed that thread somehow Peter but I've just ordered one of those modules to try. The wireless network 'types' your module link says it supports is: Supports three kinds of wireless network types: basic network (STA or AP), ad hoc network (Ad-hoc) The way I'm set up here at home is as Windows calls it - 'infrastructure mode' with a central router. Do those supported methods above encompass that? Greg |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
@Matherp, That module looks interesting. I am looking for a reliable wifi module as i want to put it in a remote controlled model tank. :) Do you know what kind of range you can get with the included antenna? Microblocks. Build with logic. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8592 |
Yes that is how I'm using it. I'm using it about 15m from the router with no issues but haven't done a range test. Doing the initial set up of the module can be a bit tricky. paceman PM me when you receive it if you have any issues. |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
dude, im almost there! this stays good for minutes at a time |
||||
CarlRanson Newbie Joined: 08/05/2015 Location: New ZealandPosts: 30 |
so I broke out the scope and checked the 3.3v power supply that is running the esp8266 and the display. I get a sharp drop in the voltage every 100ms. it starts at around -200mv but grows over time. once it hits about -0.5v its enough to disrupt the wifi. i removed the display and it was still there. removing the esp module made it go away. So it seems that the ESP8266 module is causing this. |
||||
Page 1 of 2 |
Print this page |