Jump to content

Search the Community

Showing results for tags 'energia ethernet'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks


There are no results to display.

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 1 result

  1. Hello all I am building a temperature logging web server around a TM4C1294 LP and several "temperature bugs", little sensors built around a MSP430G2553 and I2C temp sensors. The web server is connected with these "bugs" via NRF24 modules. (at the moment only one active) The server logs the temperature data over long time and shows them on a table. Time is synced with NTP once an hour. I am using Energia 16 Everything works fine and as expected However, the whole system is not reliable. The more often I connect via web browser, the more likely it will simply not accept any connection and crash. Sometimes o.k. for four days, sometimes crashed after 24 hours. In order to trace down the problem, I inserted the auto-refresh: client.println("<META HTTP-EQUIV=\"refresh\" CONTENT=\"10\">"); Like this it is much worse, sometimes survive for an hour, sometimes crash after 15 minutes. Having two or three browser tabs open make it worse. Once crashed, no more communication over serial any longer. Only reset helps. Heart beat LED 1 constantly off. LED 2 and 3 are constantly on. So it seems to get blocked in the printIndex function, which mostly consists of client.println calls. Any suggestions? Is there anything I am doing wrong in my Ethernet code? (It is more or less copied from the example) Anybody has a TM4C1294 Launchpad running 24/7 as a simple webserver with the ethernet library? Thanks for any help or hint // temperature logger web server // Energia0101E0016, Board:tm4c129 #define temp_array 288 #define seconds_per_sample 600 #include <Ethernet.h> #include <EthernetUdp.h> #include <time.h> #include <Enrf24.h> #include <nRF24L01.h> #include <string.h> #include <SPI.h> EthernetServer server(80); EthernetClient client; Enrf24 radio(8, 12, 11); const uint8_t rxaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 }; const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 }; byte mac[] = { 0x00, 0x1a, 0xB6, 0x02, 0xa8, 0xc2 }; byte myip[]= { 192,168,1,54}; unsigned int localPort = 8888; // local port to listen for UDP packets IPAddress timeServer(66,228,59,187); const int NTP_PACKET_SIZE= 48; // NTP time stamp is in the first 48 bytes of the message byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets unsigned long oldmillis; unsigned long oldepoch,epoch; float temperature; float temp24 [temp_array]; unsigned long time24 [temp_array]; int index24; int timeout_to_sync=30; // A UDP instance to let us send and receive packets over UDP EthernetUDP Udp; void setup() { Serial.begin(9600); Serial.println("UdpNtpClient setup"); pinMode(D1_LED, OUTPUT); pinMode(D2_LED, OUTPUT); pinMode(D3_LED, OUTPUT); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(MSBFIRST); radio.begin(); // Defaults 1Mbps, channel 0, max TX power radio.setSpeed(250000); radio.setRXaddress((void*)rxaddr); radio.setTXaddress((void*)txaddr); radio.enableRX(); // Start listening Ethernet.begin(mac,myip); Udp.begin(localPort); server.begin(); printEthernetData(); } void loop() { //read in temperature sensor (an MSP430G2553, sending the 2 bytes from an I2C temp sensor over NRF24) //once a minute char inbuf[33]; if (radio.read(inbuf)) { Serial.print("Received radio packet: "); Serial.println(inbuf[0]+inbuf[1]*256); if (inbuf[1] >> 7) { // negative temperature value temperature = float (((inbuf[1] << 1) | (inbuf[0] >> 7)) / 2 ) - 128; } else { // temperature value is positive temperature = float ((inbuf[1] << 1) | (inbuf[0] >> 7)) / 2; } Serial.print("Temperature: "); Serial.println(temperature); } //internet server starts here client = server.available(); if (client) { // if you get a client, digitalWrite(D1_LED, HIGH); Serial.print("new client on port "); // print a message out the serial port Serial.println(client.port()); String currentLine = ""; // make a String to hold incoming data from the client boolean newConnection = true; // flag for new connections unsigned long connectionActiveTimer; // will hold the connection start time int timeoutimer=millis(); while (client.connected()) { // loop while the client's connected if (newConnection){ // it's a new connection, so connectionActiveTimer = millis(); // log when the connection started newConnection = false; // not a new connection anymore } if (!newConnection && connectionActiveTimer + 1000 < millis()){ // if this while loop is still active 1000ms after a web client connected, something is wrong break; // leave the while loop, something bad happened } if (client.available()) { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.print(c); if (c == '\n') { // that's the end of the client HTTP request, so send a response: if (currentLine.length() == 0) { break; } else { // if you got a newline, then clear currentLine: currentLine = ""; } } else if (c != '\r') { // if you got anything else but a carriage return character, currentLine += c; // add it to the end of the currentLine } if (currentLine.endsWith("GET / ")){ digitalWrite(D2_LED, HIGH); printIndex(); digitalWrite(D2_LED, LOW); } } } client.stop(); digitalWrite(D1_LED, LOW); } // one second tick if (millis()>=(oldmillis+980)) digitalWrite(D3_LED, HIGH); if (millis()>=(oldmillis+1000)){ oldmillis=millis(); epoch++; digitalWrite(D3_LED, LOW); //sample the temperature into an array every now and then if(epoch%seconds_per_sample==0){ index24++; if (index24>=temp_array) index24=0; time24[index24]=epoch; temp24[index24]=temperature; } //short time after startup, then once an hour, sync with time server timeout_to_sync--; if(timeout_to_sync==1){ Serial.println("prepare sync with time server..."); sendNTPpacket(timeServer); // send an NTP packet to a time server } if (!timeout_to_sync){ timeout_to_sync=3600; if ( Udp.parsePacket() ) { // We've received a packet, read the data from it Serial.println("we got a signal..."); Udp.read(packetBuffer,NTP_PACKET_SIZE); // read the packet into the buffer unsigned long highWord = word(packetBuffer[40], packetBuffer[41]); unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]); // combine the four bytes (two words) into a long integer // this is NTP time (seconds since Jan 1 1900): unsigned long secsSince1900 = highWord << 16 | lowWord; // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: const unsigned long seventyYears = 2208988800UL; // subtract seventy years: epoch = secsSince1900 - seventyYears; epoch+=3600; //we are not in greenwich; +7200summmer, +3600winter oldepoch=epoch; } else{ Serial.println("sync failed!"); } } } } void printIndex(){ client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println(); client.println("<html><head><title>Maelli 02</title></head><body align=left>"); client.println("<h1> <font color=\"red\">my little temp logger</font>"); client.println("<h2> <font color=\"green\">Current date is "); // UTC is the time at Greenwich Meridian (GMT) timeprint(epoch); client.println("</br><font color=\"blue\">Temperature now is: "); client.print(temperature); client.print(char(176)); client.println("C</font></h2>"); int index=index24+1; for (int a=0; a<temp_array; a++){ if (index) index--; else index=index+(temp_array-1); timeprint(time24[index]); client.println(" - "); client.print(temp24[index]); client.print(char(176)); //