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
Related
In the C file in simplesample_mqtt.c, which connects Arduino to the Azure IoT hub, I need to use the IRsend and IrRemoteESP8266 libraries to send an infrared signal with Azure IoT hub.
#include <IRremoteESP8266.h>
#include <IRsend.h>
IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)
I don't have any problem when I use this code in my main Ardunio file. But when I use these includes in a C file (implesample_mqtt.c), I get this error from line 3: "unknown type name 'IRsend'".
error full info :
Arduino: 1.8.2 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 115200, 4M (3M SPIFFS)"
In file included from sketch\simplesample_mqtt.c:29:0:
C:\Program Files (x86)\Arduino\libraries\IRremoteESP8266\src/IRsend.h:29:1: error: unknown type name 'class'
class IRsend {
C:\Program Files (x86)\Arduino\libraries\IRremoteESP8266\src/IRsend.h:29:14: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
class IRsend {
simplesample_mqtt.c:31: error: unknown type name 'IRsend'
IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)
simplesample_mqtt.c:31: error: expected declaration specifiers or '...' before numeric constant
IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)
exit status 1
unknown type name 'IRsend'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I solved this problem. The reason for this is because main ardunio is c++ and simplesample_mqtt.c is c code and we have to use c++ code in c code :
i main ardunio file you have to declare function like this :
extern "C" void TurnOn();
void TurnOn()
{
digitalWrite(RELAY_SONOFF, HIGH);
digitalWrite(LED_SONOFF, HIGH);
}
and use this function in c code :
void TurnOn();
EXECUTE_COMMAND_RESULT TurnOn(ContosoAnemometer* device)
{
(void)device;
TurnOn();
(void)printf("Turning fan on.\r\n");
return EXECUTE_COMMAND_SUCCESS;
}
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 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!
This is my first time using QMap and I don't know what I'm doing wrong.
#include <QMap>
QMap<QString, int> name_sec_age;
name_sec_age.insert("willy", 593381460);
my errors are:
"unknown type name 'name_sec_age'"
and "expected unqualified id"
I'm using Qt Creator 4.0 with Qt 5.6 on a mac.
Side note: the run button on Qt Creator isn't available. To run my app I build it and then open the app from its path in finder. rather annoying.
You can't run code in the wild like that, it needs to be in a function.
#include <QMap>
#include <QString>
#include <QDebug>
int main() {
QMap<QString, int> name_sec_age;
name_sec_age.insert("willy", 593381460);
qDebug() << name_sec_age;
}
Your setup must be messed up somehow. Perhaps you'll have more luck by installing macports and using Qt/Qt Creator from there.
The following compiles just fine for me under Qt 5.5.1:
#include <QMap>
int main() {
QMap<QString, int> name_sec_age;
name_sec_age.insert("willy", 593381460);
}
I have recently installed MS Visual Studio 2015 with the Arduino plugin "Visual Micro".
Everything works fine, upload a sketch etc. Except when I try to compile my code when I use FreeRTOS. I downloaded the FreeRTOS libary through the Arduino IDE (library manager). Therefore(in MS VS 2015) I could chose to include the library in MS VS 2015. So I included the library in one of my sketches. Below you see my code example. Within the Arduino IDE i can compile the code and upload it to the device, but in MS VS there are some errors.
#include <timers.h>
#include <task.h>
#include <StackMacros.h>
#include <semphr.h>
#include <queue.h>
#include <projdefs.h>
#include <portmacro.h>
#include <portable.h>
#include <mpu_wrappers.h>
#include <list.h>
#include <FreeRTOSVariant.h>
#include <FreeRTOSConfig.h>
#include <event_groups.h>
#include <croutine.h>
#include <Arduino_FreeRTOS.h>
//define Tasks
void TaskBlinkSlow(void *pvParameters);
void TaskBlinkFast(void *pvParameters);
void setup()
{
/* add setup code here */
xTaskCreate(TaskBlinkSlow, "TaskSlow", 128, NULL, 1, NULL);
xTaskCreate(TaskBlinkFast, "TaskFast", 128, NULL, 2, NULL);
pinMode(13, OUTPUT);
}
void loop()
{
//Empty, things are done in tasks!!!
}
void TaskBlinkSlow(void * pvParameters)
{
for (;;) {
for (int i = 0; i < 8; i++) {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}
void TaskBlinkFast(void * pvParameters)
{
for (;;) {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
}
At the end of this post you will find the short snippet of the compilers error log. Maybe someone already came around the same issue and has a quick fix.
An example debugger breakpoint has been created. To switch the demo
breakpoint off, deselect Visual Micro>Tutorial Mode.
Compiling debug version of 'FreeRTOS' for 'Arduino/Genuino Uno'
FreeRTOS.ino:In file included from timers.h:75:3: error: #error
"include Arduino_FreeRTOS.h must appear in source files before include
timers.h" :#error "include Arduino_FreeRTOS.h must appear in source
files before include timers.h" timers.h:In file included from
FreeRTOS.ino:from task.h:75:3: error: #error "include
Arduino_FreeRTOS.h must appear in source files before include task.h"
:#error "include Arduino_FreeRTOS.h must appear in source files before
include task.h" task.h:In file included from timers.h:from
FreeRTOS.ino:from list.h:99:3: error: #error Arduino_FreeRTOS.h must
be included before list.h :#error Arduino_FreeRTOS.h must be included
before list.h FreeRTOS.ino:In file included from semphr.h:74:3: error:
error "include Arduino_FreeRTOS.h" must appear in source files before "include semphr.h" :#error "include Arduino_FreeRTOS.h" must appear in
source files before "include semphr.h" semphr.h:In file included from
FreeRTOS.ino:from queue.h:75:3: error: #error "include
Arduino_FreeRTOS.h" must appear in source files before "include
queue.h" :#error "include Arduino_FreeRTOS.h" must appear in source
files before "include queue.h" FreeRTOS.ino:In file included from
list.h:99:3: error: #error Arduino_FreeRTOS.h must be included before
list.h :#error Arduino_FreeRTOS.h must be included before list.h
task.h:In file included from timers.h:from FreeRTOS.ino:from
list.h:184:22: error: 'TickType_t' does not name a type
:configLIST_VOLATILE TickType_t xItemValue; *< The value being
listed. In most cases this is used to sort the list in descending
order. * list.h:196:22: error: 'TickType_t' does not name a type
:configLIST_VOLATILE TickType_t xItemValue list.h:208:22: error:
'UBaseType_t' does not name a type :configLIST_VOLATILE UBaseType_t
uxNumberOfItems list.h:386:47: error: expected initializer before
'PRIVILEGED_FUNCTION :void vListInitialise( List_t * const pxList )
PRIVILEGED_FUNCTION list.h:397:55: error: expected initializer before
'PRIVILEGED_FUNCTION :void vListInitialiseItem( ListItem_t * const
pxItem ) PRIVILEGED_FUNCTION list.h:410:77: error: expected
initializer before 'PRIVILEGED_FUNCTION :void vListInsert( List_t *
const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION
list.h:431:80: error: expected initializer before 'PRIVILEGED_FUNCTION
:void vListInsertEnd( List_t * const pxList, ListItem_t * const
pxNewListItem ) PRIVILEGED_FUNCTION list.h:446:1: error: 'UBaseType_t'
does not name a type :UBaseType_t uxListRemove( ListItem_t * const
pxItemToRemove ) PRIVILEGED_FUNCTION timers.h:In file included from
FreeRTOS.ino:from task.h:109:20: error: ISO C++ forbids declaration of
'BaseType_t' with no type [-fpermissive] :typedef BaseType_t
(*TaskHookFunction_t)( void * ) task.h:109:20: error: typedef
'BaseType_t' is initialized (use decltype instead) task.h:109:22:
error: 'TaskHookFunction_t' was not declared in this scope :typedef
BaseType_t (*TaskHookFunction_t)( void * ) timers.h:In file included
from FreeRTOS.ino:from task.h:136:2: error: 'BaseType_t' does not name
a type :BaseType_t xOverflowCount task.h:137:2: error: 'TickType_t'
does not name a type :TickType_t xTimeOnEntering task.h:146:2: error:
'uint32_t' does not name a type :uint32_t ulLengthInBytes
task.h:147:2: error: 'uint32_t' does not name a type :uint32_t
ulParameters task.h:155:2: error: 'TaskFunction_t' does not name a
type :TaskFunction_t pvTaskCode task.h:157:2: error: 'uint16_t' does
not name a type :uint16_t usStackDepth task.h:159:2: error:
'UBaseType_t' does not name a type :UBaseType_t uxPriority
task.h:160:2: error: 'StackType_t' does not name a type :StackType_t
*puxStackBuffer task.h:161:27: error: 'portNUM_CONFIGURABLE_REGIONS' was not declared in this scope :MemoryRegion_t xRegions[
portNUM_CONFIGURABLE_REGIONS ] task.h:170:2: error: 'UBaseType_t' does
not name a type :UBaseType_t xTaskNumber; * A number unique to the
task. * task.h:172:2: error: 'UBaseType_t' does not name a type
:UBaseType_t uxCurrentPriority; * The priority at which the task was
running (may be inherited) when the structure was populated. *
task.h:173:2: error: 'UBaseType_t' does not name a type :UBaseType_t
uxBasePriority; * The priority to which the task will return if the
task's current priority has been inherited to avoid unbounded priority
inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is
defined as 1 in FreeRTOSConfig.h. * timers.h:In file include
If you read the error messages, the issue is explained clearly.
include Arduino_FreeRTOS.h must appear first.
Your example shows it included last.
Put it first and the errors will go away.
Arduino_FreeRTOS.h includes many definitions that are used in other places, hence the need for it to be first.
Unrelated to your question, but using delay() is nasty as it consumes CPU cycles needlessly. Try vTaskDelay() as alternative which defers (or blocks) to the Scheduler to unblock other Tasks or run the idle Task which is the Arduino loop() function.
The loop() function can then put the CPU to sleep, reducing power consumption. See the feilipu.me post on topic for more.
vTaskDelay() counts Ticks, so hence the need to divide by the Tick period in milliseconds. i.e.
Time in ms / portTICK_PERIOD_MS = Ticks
#include <Arduino_FreeRTOS.h>
#include <croutine.h>
#include <event_groups.h>
#include <FreeRTOSConfig.h>
#include <FreeRTOSVariant.h>
#include <list.h>
#include <mpu_wrappers.h>
#include <portable.h>
#include <portmacro.h>
#include <projdefs.h>
#include <queue.h>
#include <semphr.h>
#include <Stack_Macros.h>
#include <task.h>
#include <timers.h>
void setup()
{
}
void loop()
{
}
Found the issue, the includes where in the wrong order: dont know why;).
You cant only include freeRTOS in MS VS you need to correct the order of the includes by yourself.
Here is the correct order:
#include <Arduino_FreeRTOS.h>
#include <croutine.h>
#include <event_groups.h>
#include <FreeRTOSConfig.h>
#include <FreeRTOSVariant.h>
#include <list.h>
#include <mpu_wrappers.h>
#include <portable.h>
#include <portmacro.h>
#include <projdefs.h>
#include <queue.h>
#include <semphr.h>
#include <StackMacros.h>
#include <task.h>
#include <timers.h>
I'm not sure about the Arduino code you are referring to, but normally there is no reason to include FreeRTOSConfig.h directly - instead include FreeRTOS.h first, and that will get the ordering of the port layer files and FreeRTOSConfig.h files correct for you, then include the header files that contain the API functions you want to use.