I've bought a shiny new SIM7000 GSM/LTE module that I've managed to get working with Espruino Pico.
My problem is that the USART interface stops working when I disconnect the Pico from the USB port and power it from a LiPo battery. I first used Serial1 with USB.setConsole(true), then tried Serial2 instead, without noticing any difference. The code runs fine, logging any errors to an array so I can check it later. But the USART connection goes quiet as soon as USB is disconnected – any AT commands sent to the module never get a response. If I connect it to the USB port again and use the Web IDE, everything is back to normal.
What could be going on? Is there something obvious that I've missed when setting up USART?
I should mention that I've actually made my own version of the AT module, using promises instead of callbacks, plus a few other changes that I needed in order to get it to work with SIM7000 (and to understand what it was doing – really good programming excercise!). While the bug could lie somewhere in that code, it does work perfectly fine when connected to USB.
Relevant excerpts from my code (yes, no semicolons!):
const USART = Serial2
const BAUD = 115200
const PWRKEY = B4
const at = require('AT').setup(USART)
// Enable the PWRKEY pin
pinMode(PWRKEY, 'output')
// Enable Espruino's deep sleep mode
setDeepSleep(true)
// Deal with any uncaught exceptions
process.on('uncaughtException', logError)
E.on('init', () => {
USB.setConsole(true)
USART.setup(BAUD)
})
function test() {
digitalPulse(PWRKEY, LOW, 100) // Power on
// Listen for "SMS Ready" URC, time out after 10 seconds
at.listen('SMS Ready', 10000) // similar to at.register() in the official module
.then(…) // do stuff
.catch(logError) // logs error to an array for later retrieval
// When connected to USB, it receives "SMS Ready" 100% of the time
// When connected to battery only, the SIM7000 module powers on but at.listen() times out with nothing being received
// When connected back to USB again (without rebooting), AT commands are received
}
I'm programming the Pico from the Web IDE using "Save on Send: Direct to Flash".
I've also tried putting USB.setConsole(true) at the very top of the code.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I've bought a shiny new SIM7000 GSM/LTE module that I've managed to get working with Espruino Pico.
My problem is that the USART interface stops working when I disconnect the Pico from the USB port and power it from a LiPo battery. I first used
Serial1
withUSB.setConsole(true)
, then triedSerial2
instead, without noticing any difference. The code runs fine, logging any errors to an array so I can check it later. But the USART connection goes quiet as soon as USB is disconnected – any AT commands sent to the module never get a response. If I connect it to the USB port again and use the Web IDE, everything is back to normal.What could be going on? Is there something obvious that I've missed when setting up USART?
I should mention that I've actually made my own version of the AT module, using promises instead of callbacks, plus a few other changes that I needed in order to get it to work with SIM7000 (and to understand what it was doing – really good programming excercise!). While the bug could lie somewhere in that code, it does work perfectly fine when connected to USB.
Relevant excerpts from my code (yes, no semicolons!):
I'm programming the Pico from the Web IDE using "Save on Send: Direct to Flash".
I've also tried putting
USB.setConsole(true)
at the very top of the code.Any help would be greatly appreciated!