Diferent boards on Arduino IDE

I do not understand how the Adruino supports diferent boards

I have an arduino MEGA board.

I need to use the same programming environment to program a BLUE PILL, which is a 3.3V system STM ARM uP. Will the same libraries work? Ie if I use an accelerometer or temperature chip, will the same library code work?

How do I add the Blue Pill board to my IDE environment so that I can choose to work with the BLUE PILL

Hi Clem,

You can find installation instructions for the Blue Pill here:
https://wiki.stm32duino.com/index.php?title=Installation

Libraries will not work universally between boards. You will probably be able to use the same libraries. If you need to be sure they will work you could use an Arduino equivalent of the Blue Pill.

Let me know if you have any questions!

Hi Stephen,

I don’t know where to go?

I have loaded the software and opened a simple blink example sketch and sometimes it downloads the compiled code othert times it gives the message: Couldn’t find the DFU device: [LEAF:0003]

The BLUE PULL green led blinks while downloading or trying to download and then does nothing!

Hi Clem,

In your sketches you will need to write to PB13 to control the LED. In your screenshots, you have 33 and PB1. As far as it not working sometimes, I’m not familiar with this board. Is there a reason that you are using this over other models?

I changed to PB13 and still no difference.

I selected BLUE PILL because of some YTube video I watched - I cannot remember the precise reason other than I wanted to use the STM32 ARM processor which I think is much better. Also simple small low cost system.

Regards

Hi Clem,

It could be that you need to hit the reset button before uploading? I’m not sure what else the problem might be. Sorry!

Hi Stephen,

Resetting did not help either.

Do you sell any board similar to the BLUE PILL which has an ARM STE23 processor - this is essential requirement.

Regards

Looks like there are a few flavours of STM32 boards in the wild

Are these able to be programmed via the Arduino IDE?

That might not always be the case; it would be best to check the product page and follow the links to guides. I don’t have a lot of experience with them; though they are popular enough in maker-circles

I tried to post on forum but could not work out how to encapsulate the code:

LIS3DH interface

It is unclear to me which pins of the sensor need to be connected Clk. D, CE to which pins of the MAXIM board in these examples and is this using I2C or SPI communication. ??? And do they use different pins for each type of communication? This is a simple question but I have no idea how to easily navigate the code to find out and how to change the pins for same function.

// Basic demo for accelerometer readings from Adafruit LIS3DH

#include <Wire.h>

#include <SPI.h>

#include <Adafruit_LIS3DH.h>

#include <Adafruit_Sensor.h>

// Used for software SPI

#define LIS3DH_CLK 13

#define LIS3DH_MISO 12

#define LIS3DH_MOSI 11

// Used for hardware & software SPI

#define LIS3DH_CS 10

// software SPI

//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);

// hardware SPI

//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);

// I2C

Adafruit_LIS3DH lis = Adafruit_LIS3DH();

#if defined(ARDUINO_ARCH_SAMD)

// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!

#define Serial SerialUSB

#endif

void setup(void) {

#ifndef ESP8266

while (!Serial); // will pause Zero, Leonardo, etc until serial console opens

#endif

Serial.begin(9600);

Serial.println(“LIS3DH test!”);

if (! lis.begin(0x18)) { // change this to 0x19 for alternative i2c address

Serial.println(“Couldnt start”);

while (1);

}

Serial.println(“LIS3DH found!”);

lis.setRange(LIS3DH_RANGE_4_G); // 2, 4, 8 or 16 G!

Serial.print("Range = "); Serial.print(2 << lis.getRange());

Serial.println(“G”);

}

void loop() {

lis.read(); // get X Y and Z data at once

// Then print out the raw data

Serial.print("X: "); Serial.print(lis.x);

Serial.print(" \tY: "); Serial.print(lis.y);

Serial.print(" \tZ: "); Serial.print(lis.z);

/* Or…get a new sensor event, normalized */

sensors_event_t event;

lis.getEvent(&event);

/* Display the results (acceleration is measured in m/s^2) */

Serial.print("\t\tX: "); Serial.print(event.acceleration.x);

Serial.print(" \tY: "); Serial.print(event.acceleration.y);

Serial.print(" \tZ: "); Serial.print(event.acceleration.z);

Serial.println(" m/s^2 ");

Serial.println();

delay(200);

}

// Basic demo for tap/doubletap readings from Adafruit LIS3DH

#include <Wire.h>

#include <SPI.h>

#include <Adafruit_LIS3DH.h>

#include <Adafruit_Sensor.h>

// Used for software SPI

#define LIS3DH_CLK 13

#define LIS3DH_MISO 12

#define LIS3DH_MOSI 11

// Used for hardware & software SPI

#define LIS3DH_CS 10

// software SPI

//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);

// hardware SPI

//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);

// I2C

Adafruit_LIS3DH lis = Adafruit_LIS3DH();

#if defined(ARDUINO_ARCH_SAMD)

// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!

#define Serial SerialUSB

#endif

// Adjust this number for the sensitivity of the ‘click’ force

// this strongly depend on the range! for 16G, try 5-10

// for 8G, try 10-20. for 4G try 20-40. for 2G try 40-80

#define CLICKTHRESHHOLD 80

void setup(void) {

#ifndef ESP8266

while (!Serial); // will pause Zero, Leonardo, etc until serial console opens

#endif

Serial.begin(9600);

Serial.println(“Adafruit LIS3DH Tap Test!”);

if (! lis.begin(0x18)) { // change this to 0x19 for alternative i2c address

Serial.println(“Couldnt start”);

while (1);

}

Serial.println(“LIS3DH found!”);

lis.setRange(LIS3DH_RANGE_2_G); // 2, 4, 8 or 16 G!

Serial.print("Range = "); Serial.print(2 << lis.getRange());

Serial.println(“G”);

// 0 = turn off click detection & interrupt

// 1 = single click only interrupt output

// 2 = double click only interrupt output, detect single click

// Adjust threshhold, higher numbers are less sensitive

lis.setClick(2, CLICKTHRESHHOLD);

delay(100);

}

void loop() {

uint8_t click = lis.getClick();

if (click == 0) return;

if (! (click & 0x30)) return;

Serial.print(“Click detected (0x”); Serial.print(click, HEX); Serial.print("): ");

if (click & 0x10) Serial.print(" single click");

if (click & 0x20) Serial.print(" double click");

Serial.println();

delay(100);

return;

}

Conversation continues here: LIS3DH interface