Arduino class HWSerial' has no member named 'read' - arduino

I am using the GSMSHIELD library with an Arduino Mega and I am getting the following error on two different systems.
/Users/-----/Documents/Arduino/libraries/GSMSHIELD/SIM900.cpp: In member function 'int SIMCOM900::configandwait(char*)':
/Users/-----/Documents/Arduino/libraries/GSMSHIELD/SIM900.cpp:62:18: error: 'class HWSerial' has no member named 'read'
connCode=_cell.read();
I can trace this back through the GSM.h file:
#include "HWSerial.h"
...
HWSerial _cell;
and the Arduino HardwareSerial.h file:
public:
inline HardwareSerial(
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *ucsrc, volatile uint8_t *udr);
void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
void begin(unsigned long, uint8_t);
void end();
virtual int available(void);
virtual int peek(void);
virtual int read(void);
<snip>
I can't for the life of me figure out why this won't compile, unless it's an Arduino development system version (1.6.9) issue...
I don't find any info on which versions of the IDE the library was written/tested on.
Any ideas?

Make sure you uncomment the first line in HWSerial.h from //#define MEGA to #define MEGA
There are two places for you to uncomment the define in order for you to use Mega instead of Uno board. That is in GSM.h and HWSerial.h!

Related

Arduino Nano communication with ST7735 over SPI-Bus

I use an Arduino Nano with a ST7735 display and a CAN controller MCP2515. Via SPI bus I want to communicate with the display and the CAN controller. The communication via CAN controller works smoothly. With the display I have the problem that it only shows a white screen.
This is my current setup:
CAN-Setup as picture
I use this kind of code to communicate with the CAN-Controller and with the display:
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <SPI.h>
#include <mcp2515.h>
#define MCP2515_CS 10 // Chip Select CAN-Controller
#define TFT_CS 7 // Chip Select TFT-Display
#define TFT_RST 8 // Reset
#define TFT_DC 9
#define TFT_MOSI 11 // Data out
#define TFT_SCLK 13 // Clock out
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
struct can_frame canMsg;
MCP2515 mcp2515(MCP2515_CS);
Can anyone spot a bug?
In Adafruit libraries the constructors where you enter the SPI pins use software SPI (bit banged). It conflicts with hardware SPI for the CAN controller on the same pins. Use the constructor
Adafruit_ST7735(int8_t cs, int8_t dc, int8_t rst);
so
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

ESP8266 (Nodemcu) + PN532 (RFID) + ST7735 (Display) in one setup possible?

I am trying to get an RFID-Reader (PN532) to work with a display, so it is shown there, who has scanned his RFID-Card.
The problem I ran into was, that 2 pins (D7 HMOSI) and (D5 HSLCK) are used by both devices. Thus I simply put both connections on those. (wrong?)
Now when initializing either of both devices, the other one gets disabled.
I use Adafruit to initialize both devices.
In addition to this, the ESP8266 does not start when the RFID-Reader is connected. Removing the Pin from 3.3Volt VCC and waiting for init, then Adding the Pin, only then the RFID-Reader gets recognized and the ESP8266 runs. (bad case for crashes, as it would never reboot)
This is my cable setup:
Also here is my code:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#define PN532_SCK (14)
#define PN532_MOSI (13)
#define PN532_SS (15)
#define PN532_MISO (12)
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#define TFT_CS 5
#define TFT_RST 16
#define TFT_DC 4
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
void testdrawtext(char *text, uint16_t color) {
tft.setCursor(0, 0);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
}
void setup(void) {
Serial.begin(9600);
Serial.print(F("Hello! ST7735 TFT Init"));
tft.initR(INITR_BLACKTAB); // Init ST7735 chip, black tab
Serial.println(F("Initialized"));
tft.fillScreen(ST77XX_BLACK);
while (!Serial) delay(10);
Serial.println("Hello! PN532 RFID Init");
nfc.begin(); // Init PN532 chip
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN532 board");
while (1); // halt
}
// Got ok data, print it out!
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
nfc.setPassiveActivationRetries(0xFF);
nfc.SAMConfig();
Serial.println("Waiting for a Card");
}
The constructor
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
creates a 'driver' which uses software SPI. But you supply pins of hardware SPI as parameters. Hardware SPI is used by the Adafruit_ST7735 library over the SPI library to access the display so hardware SPI conflicts with the software SPI of the PN532 library.
Use
Adafruit_PN532 nfc(PN532_SS);
constructor which uses the hardware SPI over the SPI library. The SPI library 'knows' the pin numbers of the SPI pins. (SPI library is part of the boards package. It can't be installed separately.)
And don't use SS (io 15) as CS. Use a different pin. io 15 is a boot configuration pin and must be LOW at boot.

Digispark micro + SSD1306 - compilation error

I'm the owner the Digispark micro and gm009605v4 OLED display. But I'm not able compile this project
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_Address 0x3C
Adafruit_SSD1306 oled(1);
void setup() {
oled.begin(SSD1306_SWITCHCAPVCC, OLED_Address);
}
void loop() {
oled.clearDisplay();
oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.println("Hello!");
oled.display();
}
The error message is
Arduino: 1.8.12 (Windows 10), Board: "Digispark (Default - 16.5mhz)"
In file included from C:\Users\lin\Documents\Arduino\sketch_jun11a\sketch_jun11a.ino:1:0:
C:\Users\lin\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:113:28: error: '__FlashStringHelper' does not name a type
void getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
^
C:\Users\lin\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:113:49: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
void getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
^
In file included from c:\users\lin\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5\avr\include\avr\io.h:99:0,
from c:\users\lin\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5\avr\include\avr\interrupt.h:38,
from C:\Users\lin\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/WProgram.h:8,
from C:\Users\lin\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Arduino.h:4,
from sketch\sketch_jun11a.ino.cpp:1:
And more....
Can you help me, please? I have installed latest Adafruit SSD1306. Or is there another library for work with this display? Noone example I found and tried worked for me
Adafruit has stated the following:
It will compile if you set the processor to digispark pro.
Why it is that way is known to them.
EDIT: The problem was solved - New problem TwoWire does not name a type. Solution for that:
The adafruit library is directly referencing the TwoWire class which is normally defined in wire.h. For the Digistump boards, they have a similar class but it is called WUI_TWI, not TwoWire.
Probably the easiest way to fix this would be to modify the wire.h file that came from Digistump. add this near the end of the file wire.h
extern USI_TWI Wire;
#define TwoWire USI_TWI // add this line
#endif
The wire.h file (in windows) will be located in
C:\Users\YOUR_USERNAME\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\Wire
make sure it is this one for digistump with the USI_TWI class, not the standard arduino one with the TwoWire class

Interfacing with SparkFun mpu-6050 with a Texas Instruments TM4C123G LaunchPad

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.

Nodemcu 1.0 with arduino ide, collaborator cannot compile sketch but i can

We are making a weather station project at our school together with my teammate, both are using windows pc:s with arduino ide to program Nodemcu 1.0.
This sketch compiles without trouble on my pc with installed libraries (adafruit dht library 1.3.0 and adafruit unified sensor library 1.0.2).
Teammate reports of error when compiling:
\Documents\Arduino\libraries\Adafruit_Sensor-1.0.1\Adafruit_Sensor.cpp:2:26: fatal error: avr/pgmspace.h: No such file or directory
#include <avr/pgmspace.h>
^
compilation terminated.
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
we have compared libraries and both should have the same libraries installed.
#include "DHT.h"
#define DS18B20pin 4 //määritetään DS18B20 -sensorin datapin. Nodemcu pin D2 = GPIO 04
#define DHTPIN 5 //määritetään DHT11-sensorin datapin. Nodemcu pin D1 = GPIO 05.
#define LDRpin A0 //määritetään LDR-vastukselle A0 -pinni.
#define DHTTYPE DHT11 //määrittää DHT-sensorisarjasta että on DHT11 käytössä.
int DHTvalue; //DHT11 - Suhteellinen ilmankosteus prosentteina
float DSvalue; //DS18B20 - Lämpötila celciusasteina
int LDRvalue; //LDR - Valon määrä prosentteina
DHT dht(DHTPIN, DHTTYPE);
void setup() {
pinMode(DS18B20pin, INPUT);
Serial.begin(115200); //alustetaan sarjaportti ja nopeus.
dht.begin(); //alustetaan dht-kirjastosta sensori.
}
void loop() {
delay(2000); //DHT11 vaatii vähintään 2 sekunnin delayn lukujen välillä.
//luetaan valon määrä LDR-vastukselta ja tulostetaan se sarjaportille.
int ldr_lukema = analogRead(LDRpin);
LDRvalue = ldr_lukema * (100 / 1023.0); //muutetaan 0-1023 arvoinen analogiarvo prosenteiksi 0-100.
Serial.print("Valon määrä(%): ");
Serial.println(LDRvalue);
//Tarkistetaan että DHT11 lukemat ovat ok.
Serial.print("Ilmankosteusanturin tila: ");
int dht11_tila = dht.readHumidity();
if(isnan(dht11_tila)){
Serial.println("virhe");
}else{
Serial.println("OK");
}
Serial.print("Ilman suhteellinen kosteus(%): ");
Serial.println((float)dht.readHumidity());
Serial.println("-----------------------------------------------");
}
The problem is your teammate is using a different version of the Adafruit Unified Sensor Driver library. As you can see from the error message:
\Documents\Arduino\libraries\Adafruit_Sensor-1.0.1\Adafruit_Sensor.cpp:2:26: fatal error: avr/pgmspace.h: No such file or directory
they are using version 1.0.1 and you are using 1.0.2. The unnecessary include of avr/pgmspace.h was removed between those two versions.

Resources