NodeMCU and SIM800L

Posted on
  • Can someone help me understand how to implement SIM800L on NodeMCU 1.0?!
    I connected:

    • pin rx from sim800 to tx of NodeMCU,
    • pin tx from sim800 to rx of NodeMCU,
    • vcc from sim800 to 3.3v of NodeMCU,
    • gnd from sim800 to gnd of NodeMCU,
    • rst from sim800 to D5 of NodeMCU

    Then i got this code:

    var wifi = require('Wifi');
    var esp = require('ESP8266');
    var sim = require('SIM900');
    
    wifi.connect("...........", {password:'...............'}, function(err) {
          if (err) throw err;
          console.log("Connected to wifi");
          console.log(wifi.getIP().ip);
    });
    
    var gprs = sim.connect(Serial1, D5, function(err) {
      if (err) throw err;
      gprs.connect('mobile.vodafone.it', '', '', function(err) {
        if (err) throw err;
        gprs.getIP(function(err, ip) {
          if (err) throw err;
          console.log('IP:' + ip);
          require("http").get("http://www.pur3.co.­uk/hello.txt", function(res) {
            console.log("Response: ",res);
            res.on('data', function(d) {
              console.log("--->"+d);
            });
          });
        });
      });
    });
    

    I got console stopping to work.
    I even thought that as NodeMCU is connected to usb and maybe tx and rx of NodeMCU somehow conflict with usb then i changed on code "serial1" to serial2 or serial3 but nothing.
    Then as i thought about the conflict i connected and saved wifi so that i can connect to NodeMCU through wifi for IDE and then send serial connect on next reboot but nothing.
    Well ... can someone tell me how it works please?
    Thanks

  • As far as I know, ESP8266 has 1.5 Serial ports. Serial1 can TX and RX (but is connected to Serial on NodeMCU), and Serial2 can only TX.

    You might be able to connect to the ESP8266 over Wifi using Telnet, but you still have the problem that USB is physically connected to Serial1, so will conflict with the SIM800 unless you can disable it somehow.

    Unfortunately you may be out of luck unless you're willing to use something like Espruino Wifi - that has a separate MCU with two serial ports (one for Wifi, one is free), but also an entirely separate USB connection.

  • What if i connect to nodemcu over wifi plugged to a wall power supply and i connect rx tx to sim900? does it still conflict?

  • Ok i connected NodeMcu with espruino IDE through wifi and then used serial1 to comunicate to sim800L.
    Comunication now is not conflicting with the only UART available but i cannot get to work AT commands on sim800...

  • I think if you want some help you'll need to post up the code you're using, and what error messages you get (if any).

    Thinking about it, you may have some difficulty using both network interfaces at the same time - Espruino is only set up to use one.

    Still, you should be able to use just the AT commands with the SIM800 without those problems

  • You can use the main UART to attach a peripheral, but it's somewhat tricky. You will get stuff printed on it at boot, so your periph better be able to ignore that. My onInit() function when using a nextion display attached to uart0 contains:

      // change logging so we don't clobber the nextion display on uart0
      esp8266.setLog(3); // log to memory and 2:uart0 3:uart1
      console.log("Bye bye...");
      Serial2.setConsole(false)
    

    The way I use it is to upload the code using telnet, so I see the "Bye bye..." printed via telnet when I run onInit() manually. By setting Serial2 as console the characters get dropped. By not forcing the console to stick to Serial2 I can telnet into the espruino at any time and have the console back. This has worked quite well for me.

  • Hi tve,
    thanks for the advices. In the next days i'll try and let you know.

  • Hi tve,

    Did you try to connect sim800 over the software serial?

    Also if you are trying to send AT-commands to sim800 via the console you have to set NL + CR flags in the console settings.

    And are you sure that you have started sim800 correctly? Following the HW manual you should ground the PWK pin for 1 second to start the module. As for me I have two different sim800 boards. One has two leds: power led and network led. When you connect the sim800 board to a power source you see the power led is on and this may let you think that the board is really on but it is not so. When you ground the PWK as I stated above you'll also see the network led blinking which means that finally the board is really on. The second sim800 I have has only network led. The another one sim800 has only netowkr led but it is started in the similar way.

    Don't forget that sim800 consumes 2A 4.2v (or 5v depending on board model) during the Location Update procedure which means you have to use an external adapter for that. I used just 3-4 AA-batteries for test. The NodeMCU Base Shield is also not enough for such a power consumption as it can let only 1A current.

  • Hi Ivan,

    I am connecting SIM800 using Software Serial but WEMOS d1 (similar to NodeMCU) stops working. Could you please share the code you use.

    Best,
    Rodri

  • Hi Rodri,

    My test code is as follows:

    #include
    SoftwareSerial mySerial(D8, D7); // RX, TX
    void setup() {
    Serial.begin(19200); //Скорость порта для связи Arduino с компьютером

    // SIM800 PWK pin is conected to D0
    pinMode(D0, OUTPUT);

    // switching on SIM800 by powering down PWK pin for a second
    digitalWrite(D0, LOW);
    delay(1000);
    digitalWrite(D0, HIGH);

    mySerial.begin(19200);
    mySerial.println("AT");

    mySerial.begin(19200);
    delay(5000);

    if(mySerial.available())
    Serial.write(mySerial.read());
    

    // setting some parameters
    mySerial.write("AT+CMGF=1\n\r"); // SMS output text mode

    if(mySerial.available())
    Serial.write(mySerial.read());
    

    mySerial.write("AT+CNMI=1,2,2,1,0\n\r");­ // Show SMS text in output

    if(mySerial.available())
    Serial.write(mySerial.read());
    

    mySerial.write("at+clip=1\n\r"); // Calling line presentation in output
    }

    void loop() {

    // code to play with AT commands from the terminal
    if (mySerial.available())

    Serial.write(mySerial.read());
    

    if (Serial.available())

    mySerial.write(Serial.read());
    

    }

  • Hello sir,

        I want to receive sms on sim 800 using nodemcu ESP8266 on Arduino IDE. Can you please suggest the required procedure for it?
    
  • If you want to use the arduino ide - your are in the wrong forum.

    This is for espruino JavaScript, rather than compiled c.

  • our task is to receive sms and forward that sms to web server.......using nodemcu ESP8266 and sim800 ..doesnt matter which ide we r using

  • It's not just the IDE that is different. It's the whole language (JS rather than C).

    Please ask on the ESP8266 or Arduino forums - you're definitely in the wrong place.

    (You can use Espruino on ESP8266 with SIM800 if you're willing to use Telnet to program them rather than the Serial Port (although if you used an official board it'd be miles easier), but honestly I think if you haven't researched Espruino enough to realise it's not just an IDE then when you do find out more about it you'll find it's not for you).

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

NodeMCU and SIM800L

Posted by Avatar for user70656 @user70656

Actions