Arduino Uno ESP8266-01 using i2c?

Hello long story short. I been trying to track my progress of walking and standing up straight from my last car accident i been having problems walking and standing. So recently i have bought a couple of accelerometers 3 axis also some 433mhz transceivers and a few ESP8266 ones. And i been learning how to use them. It's been going good. But i thought i can show my stats online in a adrduino web server page. It didn't go well using USB. i broke 2 ports on my desktop and almost broke my laptop.

I been searching online and Trying out 433mhz transceivers. They work good however i wanted to put it online through a web server page. I do not have any Ethernet shields because most of my internet here is wireless. SO i thought i was use a ESP266 for get it online. Here is where i hit a roadblock. the accelerometer is i2c and my esp8266-01 does not have i2c So i'm using a arduino uno board for that. The only thing is sense I'm lacking programming skills and limit to what i can find online for help and to learn. I can not find something that can pass from the arduino board to the ESP8266 so the ESP8266 can be the Webserver hosting the webpage and the Uno can do the rest. Maybe I'm phrasing it wrong online i do not know But i need help is where something online i can find to do pass through like this?

Joseph

Communication between the Arduino and the ESP is usually done using SoftwareSerial. You can send anything you want from the Arduino to the ESP.

what did you try with the esp8266? did you connect it to usb with usb-to-ttl or using the usb on uno? Can you communicate with AT firmware? did you try the esp8266 arduino core package to upload a sketch to esp8266? you could modify the esp8266 WebServer example to show the values sent from uno.

and did you consider to use an nodemcu or wemos esp8266 board (they have i2c)?

Hello i have not connected the the esp yet. What i have done is Arduino uno with the accelerometers using 433mhz transmitter and a second arduino uno with a Receiver. Just viewing in Serial monitor.

But i would like to replace the Serial monitor with a ESP8266 and have it host a webserver web locally.
I'm limited on money i can not buy any more stuff for a while that is including a wemos. I would like to use what i have now If possible.

Which ESP8266 modules do you have?

I2C is available on the ESP8266. I use the -07 and -12 modules and have used I2C to communicate with sensors, Tiny85 and stand alone Mega328.

You could connect the accelerometer to the ESP8266 and eliminate the Uno. Program the ESP with the ESP8266 Arduino core to read the accel and host a web page with the data.

ESP8266 beginners guide.

Hello thought I put that in there. Sorry as bout that I have esp8266-01

Which pins of the ESP8266-01 would you use for I2C :

Hello 6v6gt the 01 module doesn't have i2c. That's why I need to use a ino hoard with the esp. Problem is sense my lack of coding not sure tut o to pass the data to the esp from the uno board so the esp will be the web server its self.

I have never used the -01 module because of the low pin count. I did a search for "esp8266-01 I2C" and got a bunch of hits. This one looks promising.

OK. I've read the OP in more detail now.

You want to collect data from I2C based accelerometers using an Arduino Uno.
You want to periodically publish this data on a web server to make the data visible through web browsers.

Is that web server an internet based service (like with PHP, MySQL, Apache etc.) or are you intending that the data is on a web server visible only in your local network ?

This will dictate whether the ESP8266 is used as a web client or as a web server.

Hello 6v6gt the esp and arduino will host the webserver page like the ethernet shield does. I just want to display the information on a webpage via the arduino and esp.

for the start it is not important if the sensor is connected. first find out if you can program the webserver and page. learn the esp8266.

I do know how to make the webserver page on the ESP that is not a problem. The problem is how to pass the data from the uno board to the ESP to display on the server page.

I did mange to find this.. I did try this and seems to work so far. Now I'm just trying figure out how to display the Sensor to the webpage.

// Code to use ESP as a basic web server
// must be connected to ESP IP to access the page (IP can be found in the serial monitor output) 
// set up Serial with newline and carriage return ("NL & CR") 
// Baud rate may differ, must be determined 
// Try 9600, 115200, or 57600

#include <SoftwareSerial.h>

//used for debugging
//when true, the ESP will print info (such as IP) to serial monitor 
#define DEBUG true
 
SoftwareSerial esp8266(2, 3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
                             // This means that you need to connect the TX line from the esp to the Arduino's pin 2
                             // and the RX line from the esp to the Arduino's pin 3
void setup()
{
  Serial.begin(115200); //baud rate may differ
  esp8266.begin(115200); // esp baud rate may differ
  
 
  //check AT commands list for more detail on each of these
  //sendData defined below, see for more detail
  sendData("AT+RST\r\n",2000,DEBUG); // reset module
  sendData("AT+CWMODE=2\r\n",1000,DEBUG); // configure as access point
  sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address
  sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections
  sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80
  //sendData("AT+CWSAP=\"OSU_ESP\",\"open\",11,3",1000,DEBUG); //set SSID, password, channel, password protection type
}
 
void loop()
{
  if(esp8266.available()) // check if the esp is sending a message 
  {
    if(esp8266.find("+IPD,")) // if user is trying to access webpage 
    {
     delay(1000);  
 
     int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns 
                                           // the ASCII decimal value and 0 (the first decimal number) starts at 48
     
     String webpage = "<h1>Hello</h1><h2>World!</h2><button>LED1</button>"; //html sent to ESP, displayed to user
                                                                            //maximum of 64 bytes sent at a time due to Arduino limit  

     // CIPSEND AT command format: AT+CIPSEND=id, length 
     String cipSend = "AT+CIPSEND="; // all data sent to ESP must be prefaced with AT+CIPSEND=
     cipSend += connectionId; //append connection id
     cipSend += ","; //must separate with comma
     cipSend +=webpage.length(); // CIPSEND requires data length as input
     cipSend +="\r\n"; //all AT commands must end with newline and carriage return
     
     sendData(cipSend,1000,DEBUG); //send AT command format
     sendData(webpage,1000,DEBUG); //your html 
     
     webpage="<button>LED2</button>"; //extra HTML 

     //see above for more detail
     cipSend = "AT+CIPSEND=";
     cipSend += connectionId;
     cipSend += ",";
     cipSend +=webpage.length();
     cipSend +="\r\n";
     
     sendData(cipSend,1000,DEBUG);
     sendData(webpage,1000,DEBUG);

     //closes the connection 
     String closeCommand = "AT+CIPCLOSE="; 
     closeCommand+=connectionId; // append connection id
     closeCommand+="\r\n";
     
     sendData(closeCommand,3000,DEBUG);
    }
  }
}
 
//timeout is the window you expect a response within
//timeout can be shortened within the function definition or in individual arugments
//If timeout is too short, not all serial data will be displayed, but webpage will load faster     
String sendData(String command, const int timeout, boolean debug)
{
    String response = "";
    
    esp8266.print(command); // send the read character to the esp8266
    
    long int time = millis();
    
    while( (time + timeout) > millis()) 
    {
      while(esp8266.available())
      {
        
        // The esp has data so display its output to the serial window 
        char c = esp8266.read(); // read the next character.
        response+=c;
      }  
    }
    
    if(debug)
    {
      Serial.print(response);
    }
    
    return response;
}

It has a hello world text on there.

Hello

World!

So this is a start.

the example with AT firmware is useless if you want to make a webserver for the esp8266.

Sorry, I ask again: can you write a webserver sketch for rhe esp8266, which will run on the esp8266? did you connect esp8266 to computer with usb-to-ttl or using the usb on uno? did you try the esp8266 arduino core package to upload a sketch to esp8266?

As already mentioned, there are 2 ways of using the ESP8266 :

  1. With the native firmware through AT commands as in your example. This is very restricted.

  2. You can load the Arduino core software onto the ESP8266 (which replaces the original firmware), then you get a much richer set of commands.

Here is an example using method 2:

https://tttapa.github.io/ESP8266/Chap10%20-%20Simple%20Web%20Server.html

In fact, the whole guide is an excellent start.

Incidentally, the ESP8266 is a 3.3 volt device and the pins are not specified as being 5 volt tolerant.

If you want to use your arduino as the microcontroller this library is useful

but, as suggested, to do advanced programming you should probably use your ESP8266 as a microcontroller.

I would recommend Node-MCU, a little more money than an esp-01, but not significantly more

Sorry for the late reply back. I just found a store about 45 minutes from me a micro center and in there wow I couldn't believe what I saw in there. It's like I was a kid in a candy store. But they had a DIY section and I found a esp-f board from adafuit huzzah. For $9.99 I looked up the board online it has i2c on it. So i will test it out. Also it has for battery on it so i can put a lipo on it as well. So I hope this will work for my walking project.