Environments
osx
esp32
vscode
platformio
I am working on an ESP32 module with this GPS module (very similar except the one I have has "ublox" logo on it - bought about 2 years ago).
#include <Arduino.h>
#include <HardwareSerial.h>
#include <TinyGPS++.h>
TinyGPSPlus gps;
HardwareSerial SerialGPS(2);
void setup() {
Serial.begin(115200); // RX TX
SerialGPS.begin(9600, SERIAL_8N1, 16, 17);
}
void loop() {
Serial.println("------------");
Serial.print("available(): ");
Serial.println(SerialGPS.available());
Serial.println("------------");
while (SerialGPS.available() > 0) {
char c = SerialGPS.read();
Serial.print(c);
gps.encode(c);
}
Serial.println();
if (gps.location.isValid()) {
Serial.print("LAT=");
Serial.println(gps.location.lat(), 6);
Serial.print("LONG=");
Serial.println(gps.location.lng(), 6);
Serial.print("ALT=");
Serial.println(gps.altitude.meters());
} else {
Serial.println("not valid");
}
delay(1000);
}
I took it outside and ran it for over 15 mins, and I see the data are still invalid.
------------
available(): 195
------------
$GPRMC,023424.00,V,,,,,,,051120,,,N*79
$GPVTG,,,,,,,,,N*30
$GPGGA,023424.00,,,,,0,00,99.99,,,,,,*65
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,1,1,00*79
$GPGLL,,,,,023424.00,V,N*49
not valid
------------
available(): 195
------------
$GPRMC,023425.00,V,,,,,,,051120,,,N*78
$GPVTG,,,,,,,,,N*30
$GPGGA,023425.00,,,,,0,00,99.99,,,,,,*64
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,1,1,00*79
$GPGLL,,,,,023425.00,V,N*48
not valid
Since I see letters coming in, I don't think TX and RX are mixed up.
I am giving it 5V (although not exactly sure if it should be 3.3v or 5v).
How can I get valid GPS data coming in from this module?
To me it looks like the GPS module is sending data properly, but hasn't got any available. It could still be looking for satellites. You can try printing the number of available ones, and simply wait longer:
Add the following lines to your program before your if statement:
Serial.println(gps.time.value()); // Raw time in HHMMSSCC format (u32)
Serial.println(gps.time.hour()); // Hour (0-23) (u8)
Serial.println(gps.time.minute()); // Minute (0-59) (u8)
Serial.println(gps.time.second()); // Second (0-59) (u8)
Serial.println(gps.satellites.value()); // Number of satellites in use (u32)
The first step should be that your GPS module gets the correct time. This should happen after a few minutes, probably. Then the number of satellites in use should go up, and you should start getting valid results once a reasonable number of satellites are found. I tend to get a reading with probably about 9 satellites.
If it is a cheaper module it might take a while, especially from a cold start.
i have seen a lot of forums where this problem is dicussed but nothing seems to work. I am working with esp32 and it was all fine untill out of nowhere this watch dog timer error came up. I am new to it so i cant really fix this.
I have another code but i copied a very simple chunk of it and created a new file but watch dog timer error is appearing here too. I dont know what the issue.
it said idle0 is not resetting watach dog timer and "wifi" task is running on cpu0.
ERROR LOG
E (42418) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (42418) task_wdt: - IDLE0 (CPU 0)
E (42418) task_wdt: Tasks currently running:
E (42418) task_wdt: CPU 0: wifi
E (42418) task_wdt: CPU 1: IDLE1
E (42418) task_wdt: Aborting.
abort() was called at PC 0x400d96f7 on core 0
Backtrace: 0x4008c470:0x3ffbe270 0x4008c6a1:0x3ffbe290 0x400d96f7:0x3ffbe2b0 0x400815dd:0x3ffbe2d0 0x40136087:0x00000000
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:10088
load:0x40080400,len:6380
entry 0x400806a4
I have tried running my task on cpu1 or core 1 too but wifi is automatically running on cpu or core0. And getting the same error.
have also tried adding delays but nothing works.
char *wssid = "PTCL-TB";
char *wpassword = "pakistan";
bool connected2Wifi = false;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(10);
Serial.println('\n');
WiFi.begin(wssid, wpassword); // Connect to the network
Serial.print("Connecting to ");
Serial.print(wssid);
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(500);
Serial.print('.');
}
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP());
}
void loop() {
// put your main code here, to run repeatedly:
} ```
I want to connect to wifi in this task. It's very simple and i have also copied it from a reliable source whose code was running. but the error seems to be rigid.
Go to Tools -> CPU Frequency and set it to 160, 80 or 240 MHz (the ones that support WiFi/BT).
I am trying to interface with the MPU-6050 as part of a robotics project using the Texas Instruments TM4C123G LaunchPad. I am uploading code onto this from Energia and am using the serial monitor to see the raw data output, however I am only receiving the following output when I upload it to the micro controller and run it:
Initialising I2C devices...
Here is the code that I am trying to run:
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
MPU6050 accelgyro;
void Setup_MPU6050()
{
Wire.begin();
Serial.println("Initialising I2C devices...");
accelgyro.initialize();
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
}
void Update_MPU6050()
{
int16_t ax, ay, az;
int16_t gx, gy, gz;
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
Serial.print("i");Serial.print("\t");
Serial.print(ax);Serial.print("\t");
Serial.print(ay);Serial.print("\t");
Serial.print(az);Serial.print("\t");
Serial.print(gx);Serial.print("\t");
Serial.print(gy);Serial.print("\t");
Serial.println(gz);
Serial.print("\n");
}
void setup()
{
Serial.begin(115200);
Setup_MPU6050();
}
void loop()
{
Update_MPU6050();
}
The pins on the breakout board are connected to the Launchpad as follows:
VDD -> Pin 1 (3.3v)
GND -> Pin 12 (GND)
INT -> Pin 34 (PF0)
FSYNC -> None
SCL -> Pin 13 (PD0)
SDA - > Pin 14 (PD1)
VIO -> None
CLK -> None
ASCL -> None
ASDA -> None
I have got the MPU6050 and I2Cdev libraries from GitHub and have got the Wire library from github.com/codebendercc/arduino-library-files/blob/master/libraries/Wire/Wire.h but am thinking that either the wire.begin() or accelgyro.initialize() methods are not functioning properly? I am a relative beginner when it comes to programming in this language but I am undertaking an ambitious task to create a robot for a scholarship that I am applying for, and would therefore appreciate some assistance on this subject area.
I just met the same question as you. Here is a useful linkage:
enter link description here
I referred it and added some code before
Wire.begin()
--just like this
enter image description here
then I upload it and run, it works perfectly. And there is another thing to be minded that you can't connect INT pin when you don't use DMP but when you use DMP then you must connect INT pin.
I try to explain it.
Why should we add the two lines codes? The Library is from Arduino, although Energia is compatible with Arduino programming in most cases but not always. So we should explictly acclaim something.
And why should we pay attention the interruption. Because when we use DMP we use it, if we don't connect the INT pin, it willn't work normally.
I have arduino micro (oryginal) like this: https://www.arduino.cc/en/Main/ArduinoBoardMicro and clone of ethernet bord with ENC28J66 chipset.
Pin configuration on ethernet board:
CKOUT
/INT
/WOL
SO
SI
SCK
/CS
/RESET
VCC (5V) (it is also possible to use 3.3V after soldering one place)
GND
I have try to run example BackSoon for EtherCard library with few combination of conection but this gave me 'Failed to access Ethernet controller'
Then i set it like this:
Micro | ENC28J60
SCK - SCK
MISO - SO
MOSI - SI
SS - CS
5V - VCC
GND - GND
10 PIN - INT
This config don't generate access error but DHCP failed. DHCP server configuration is good for sure.
Even if i set static IP address there is no respons on this IP from http like in example.
Full code of my try for dhcp:
#include <EtherCard.h>
#define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below)
#if STATIC
// ethernet interface ip address
static byte myip[] = { 172,16,10,222 };
// gateway ip address
static byte gwip[] = { 172,16,10,1 };
#endif
// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[500]; // tcp/ip send and receive buffer
const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
"<head><title>"
"Service Temporarily Unavailable"
"</title></head>"
"<body>"
"<h3>This service is currently unavailable</h3>"
"<p><em>"
"The main server is currently off-line.<br />"
"Please try again later."
"</em></p>"
"</body>"
"</html>"
;
void setup(){
Serial.begin(57600);
while (!Serial) ;
Serial.println("\n[backSoon]");
if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0)
Serial.println( "Failed to access Ethernet controller");
#if STATIC
ether.staticSetup(myip, gwip);
#else
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
#endif
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
}
void loop(){
// wait for an incoming TCP packet, but ignore its contents
if (ether.packetLoop(ether.packetReceive())) {
Serial.println("got one!");
memcpy_P(ether.tcpOffset(), page, sizeof page);
ether.httpServerReply(sizeof page - 1);
}
}
Serial response:
[backSoon]
DHCP failed
IP: 0.0.0.0
GW: 0.0.0.0
DNS: 0.0.0.0
Can someone help me to propellery connect one to another and run any sample (like BackSoon)?
Is it possibile to use Micro and ENC28J60 together?
Is it possibile to use EtherCard library for them?
Long time is passed from your question, but I hope this can help someone.
Micro - Ethernet
SCK - SCK
MISO - SO
MOSI - SI
PIN 8 - CS (8 is the default value for ethercard, 10 in your code)
5V - VCC
GND - GND
Side A:
Arduino Uno R3 with Wireless Proto shield powered with USB
With XBee Pro S1, DH 0 DL FFFF MY 0 API 0
Wireless Proto shield has the serial select switch on the 'micro' position
side B:
XBee Explorer USB connected to a PC with XCTU software
With XBee Pro S1, DH 0 DL FFFF MY 0 API 0
(When I put both XBee modules in the USB explorer boards, connected with two PC's, I can send data back and forth without any problems, so I reckon the XBee settings are good.)
The Problem
Now I want the Arduino to capture the input from the B side (send with the XCTU terminal), but when I type anything in the terminal, the RSSI LED on side A just turns on for 5 seconds, but the Arduino does not seem to capture any data since it does not send data back like it should (Serial.print("I received: ");
Arduino sketch:
int incomingByte = 0;
void setup() {
Serial.begin(19200); //Both XBee chips are configured at 19200 Baud
Serial.print("start echo machine"); //This is received just fine on the B side
}
void loop() {
if (Serial.available() > 0) {
// Read the incoming byte:
incomingByte = Serial.read();
// Say what you got:
Serial.print("I received: "); //This never shows on the B-side
Serial.println(incomingByte, DEC);
}
}
How do I fix this problem?
You have to use a SoftwareSerial(RX,TX) for the XBee and the Serial for printing the output into the pc.
RX and TX of SoftwareSerial must be linked to the DOUT and DIN pin of the module into the Wireless Proto shield:
#include <SoftwareSerial.h>
// Connect pin 10 of Arduino to DOUT of Wireless Proto shield
uint8_t ssRX = 10;
// Connect pin 11 of Arduino to DIN of Wireless Proto shield
uint8_t ssTX = 11;
SoftwareSerial nss(ssRX, ssTX);
void setup() {
Serial.begin(19200);
nss.begin(19200);
Serial.println("Serial works");
}
void loop() {
if (nss.available()){
Serial.println("received packet:");
for(int i=0;i<25;i++){
Serial.print(nss.read(),HEX);
Serial.print(",");
}
Serial.println();
}
Many of the boards require the pull-up resistor on DIN to be enabled.
According to some sources this pull-up is enabled by default on the Digi Xbee module.
To ensure it is enabled or to enable it:
Put your Xbee module in a USB explorer and use X-CTU to check the PR configuration.
DIN is on bit 7 for the Xbee Pro S1, so in that case you need the last bit to be 1.
I put it like this: 00000001
Than you convert it to hex (01 in my case) and write that value to the Xbee module with X-CTU.
So it is an electronics issue and not a programming issue.