Saying hello from turkey

Post Reply
salwan
Posts: 4
Joined: Tue Jun 20, 2017 1:27 pm

Saying hello from turkey

Post by salwan » Tue Jun 20, 2017 5:23 pm

Hi every one ;

I have question that , can i use any arduino project code in stm32f103 with just change the pins numbers ? if yes can anyone tell me how i can define stm32f103 pins as digital and analogue and interface like spi or i2c or software serial .

thanks
salwan

User avatar
zoomx
Posts: 499
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Saying hello from turkey

Post by zoomx » Tue Jun 20, 2017 7:47 pm

Hello Salwan,
start reading here
http://wiki.stm32duino.com/index.php?title=API

User avatar
RogerClark
Posts: 6918
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Saying hello from turkey

Post by RogerClark » Tue Jun 20, 2017 10:38 pm

salwan wrote:
Tue Jun 20, 2017 5:23 pm
Hi every one ;

I have question that , can i use any arduino project code in stm32f103 with just change the pins numbers ? if yes can anyone tell me how i can define stm32f103 pins as digital and analogue and interface like spi or i2c or software serial .

thanks
salwan
There are limitations on which pins can be used for hardware Serial, and SPI and Hardware I2C.
We have software I2C which can be used on any pin.

The best reference document for this is STMs own data sheet for the STM32F103C

It lists all the pins and what functions they can perform,
Note the Alternative use for each pin e.g. USART 1 is normally on PA9 and PA10 but there is also an Alternative pair or pins for USART 1
the same applies to SPI etc

Also there are multiple USARTS and multiple SPI devices e.g. you can connect 2 different SPI devices to different SPI busses ( not share SCK,MOSI,MISO )

User avatar
zoomx
Posts: 499
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Saying hello from turkey

Post by zoomx » Wed Jun 21, 2017 7:43 am

See here, for example
http://wiki.stm32duino.com/index.php?title=Blue_Pill

Wiki is the start then you can dig in the forum.

salwan
Posts: 4
Joined: Tue Jun 20, 2017 1:27 pm

Re: Saying hello from turkey

Post by salwan » Fri Jun 23, 2017 9:15 am

many thanks all for your replies , ok i will do that .

Please can you help me to change this code below from arduino uno to stm32f103 blue pill board ?

/*
Started with example code written by Nathan Seidle from SparkFun Electronics and added
LCD output with gram and ounce values.

Setup your scale and start the sketch WITHOUT a weight on the scale
Once readings are displayed place the weight on the scale
Press +/- or a/z to adjust the calibration_factor until the output readings match the known weight

Arduino pin 6 -> HX711 CLK
Arduino pin 5 -> HX711 DOUT
Arduino pin 5V -> HX711 VCC
Arduino pin GND -> HX711 GND

The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.

The HX711 library can be downloaded from here: https://github.com/bogde/HX711
*/

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);


#include "HX711.h"

#define DOUT 5
#define CLK 6

HX711 scale(DOUT, CLK);

float calibration_factor = 25.35 ; //-7050 worked for my 440lb max scale setup
float units;
float ounces;

void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 4);
lcd.setCursor(1, 0);
lcd.print("MEDICAL SCALE");
Serial.println("HX711 calibration sketch");
Serial.println("Remove all weight from scale");
Serial.println("After readings begin, place known weight on scale");
Serial.println("Press + or a to increase calibration factor");
Serial.println("Press - or z to decrease calibration factor");

scale.set_scale();
scale.tare(); //Reset the scale to 0

long zero_factor = scale.read_average(); //Get a baseline reading
Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
Serial.println(zero_factor);
}

void loop() {

scale.set_scale(calibration_factor); //Adjust to this calibration factor

Serial.print("Reading: ");
units = scale.get_units(10) , 10 ;
if (units < 500) {
units = 00 ;
}
ounces = units * 0.001;
Serial.print(units);
Serial.print(" grams");
Serial.print(" calibration_factor: ");
Serial.print(calibration_factor);
Serial.println();
////lcd.setCursor(0, 1);
////lcd.print("Grams: ");
////lcd.print(units);
lcd.setCursor(0, 2);
lcd.print("WEIGHT: ");
lcd.print(ounces , 1);
lcd.setCursor(14, 2);
lcd.print("KG");
////lcd.print(calibration_factor);

if(Serial.available())
{
char temp = Serial.read();
if(temp == '+' || temp == 'a')
calibration_factor += 1;
else if(temp == '-' || temp == 'z')
calibration_factor -= 1;
}
}

stevestrong
Posts: 1611
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Saying hello from turkey

Post by stevestrong » Fri Jun 23, 2017 9:28 am

salwan wrote:
Fri Jun 23, 2017 9:15 am

Code: Select all

LiquidCrystal lcd(8, 9, 10, 11, 12, 13);


#include "HX711.h"

#define DOUT 5
#define CLK 6
Adapt the pin numbers according to the pin functionality and the used board.
For pin numbers I would recommend to use PXY (ex: PA0, PC13) notation instead of raw numbers (2,5,6).
Last edited by stevestrong on Fri Jun 23, 2017 1:59 pm, edited 1 time in total.

zmemw16
Posts: 1418
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Saying hello from turkey

Post by zmemw16 » Fri Jun 23, 2017 10:06 am

wrap the code you the '</>' button above the compose window.

Code: Select all

my line of code
you may wish to try google with 'HX711 stm32', 1st & 3rd results look to be likely candidates for further investigation.
stephen

User avatar
ahull
Posts: 1597
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: Saying hello from turkey

Post by ahull » Fri Jun 23, 2017 7:15 pm

Data sheet for the HX711 is -> here <-
- Andy Hull -

Post Reply