arduino

Arduino Iot Project parseObject() failed

十年热恋 提交于 2020-05-17 08:47:22
问题 I'm trying to control 8 channel relay with esp8266. and i've been following this tutorial on youtube https://www.youtube.com/watch?v=dLmz0xdDOLk I did exactly what the guy said. I uploaded my code to Arduino and I get a "parseObject() failed" error on the serial monitor while the code trying to parse JSON i think(not sure). I don't really understand coding much so I wonder if you guys help me out with my project.(the only thing I couldn't do was to change my web host PHP version to 5.2, I use

Detecting and recovering from “hanging” bluetooth python connection

久未见 提交于 2020-05-17 05:59:05
问题 I have a bluetooth connection between a Raspberry Pi 3b+ and an Arduino Mega, using the RPi built-in module, and an HC-05 module on the Arduino. Bi-directional communication works like a charm, for minutes to sometimes, hours at a time. Then, at seemingly random times, the python code hangs, blocked on the sock.recv() function. I can kill it via ctrl-c, and restart it, and it usually reconnects without a problem. I know Bluetooth is a little finicky and so while any suggestions of how to make

VS Code giving header errors for Arduino? Missing official header?

╄→гoц情女王★ 提交于 2020-05-14 19:44:23
问题 I've recently started developing for Arduino. Initially I used the Arduino IDE but I soon realised it was not up to par. Development was considerably slower with the need for IDE restarts every now and then. I found VS Code with the Arduino Extension which I've come to love. However I have a few issues and I'm not sure how to solve it. First of all vs code throws #include errors and asks me to update IntelliSense. However it builds/uploads and runs perfectly well, it also finds the classes

VS Code giving header errors for Arduino? Missing official header?

三世轮回 提交于 2020-05-14 19:44:22
问题 I've recently started developing for Arduino. Initially I used the Arduino IDE but I soon realised it was not up to par. Development was considerably slower with the need for IDE restarts every now and then. I found VS Code with the Arduino Extension which I've come to love. However I have a few issues and I'm not sure how to solve it. First of all vs code throws #include errors and asks me to update IntelliSense. However it builds/uploads and runs perfectly well, it also finds the classes

About strcpy and memory on Arduino

丶灬走出姿态 提交于 2020-05-14 08:46:49
问题 I'm running this code on my Arduino Uno: #include <stdlib.h> #include <Arduino.h> #include <SoftwareSerial.h> #include <MemoryFree.h> void setup() { Serial.begin(9600); char cc[300]; char* ce = "Bonjour ca va et toi ?Bonjour ca va et toi ?Bonjour ca va et toi ?Bonjour ca va et toi ?"; strcpy(cc, ce, 300); Serial.println(getFreeMemory()); } void loop() { // Put your main code here, to run repeatedly: } So I wanted to see how much memory this was taking. And I was surprised that it was not 300

python-Arduino串口传输数据到电脑并保存至excel表格

℡╲_俬逩灬. 提交于 2020-05-07 18:24:20
  起因:学校运河杯报了个项目,制作一个天气预测的装置。我用arduino跑了BME280模块,用蓝牙模块实现两块arduino主从机透传。但是为了分析,还需要提取出数据。因此我用python写了个上位机程序,用pyserial模块实现arduiho和电脑的串口通讯,再用xlwt模块写入excel表格,用time模块获取时间作为excel的文件名。 1 import xlwt 2 import time 3 import serial 4 # 设置表格样式 5 def set_style(name,height,bold= False): 6 style = xlwt.XFStyle() 7 font = xlwt.Font() 8 font.name = name 9 font.bold = bold 10 font.color_index = 4 11 font.height = height 12 style.font = font 13 return style 14 15 # 写Excel 16 def write_excel(): 17 if serial.isOpen(): 18 print ( ' 串口已打开\n ' ) 19 f = xlwt.Workbook() 20 sheet1 = f.add_sheet( ' arduino_data ' ,cell

树莓派与Arduino串口通信

早过忘川 提交于 2020-05-07 17:51:23
咳,时隔多月又回到了熟悉的博客园。 从现在开始重新去培养写博客的习惯。 主要是用于科研技术方面的,去记录一些我的学习和思考。 会把问题尽量的具体化,新手化 一是记录方便回忆,二是梳理,三也是希望为遇到相关问题的朋友提供多多少少的借鉴和帮助吧 回归正题,如何实现树莓派与Arduino串口通信 首先是接线方式 一、树莓派与arduino通过USB进行通信 1、将树莓派与arduino通过usb线进行连接 2、在树莓派终端输入 ls /dev/tty*查看两者连接端口的名字。查看有没有ttyACM0 这个文件(注只有在两个硬件USB互连的情况下才会有这个。如果两者没有连接是不会有的) 最新的系统一般都会自动生成。看到ttyACM0就说明二者可以通讯了 接下来上测试代码。 3、编写树莓派与arduino通信代码。 arduino代码: void setup() { Serial.begin(9600); // 9600 bps } void loop() { if ( Serial.available()) { if('s' == Serial.read()) Serial.println("Hello Raspberry,I am Arduino."); } } 把上面代码通过python IDE下载到arduino中,然后再再与树莓派usb链接。 树莓派代码: import

win10上使用php与python实现与arduino串口通信

送分小仙女□ 提交于 2020-05-07 16:41:13
注意: php 需要php7,安装及开启php_dio.dll com口按照实际的进行设置,如果不知道可以打开arduino编辑器进行查看 可以与用户实现命令行交互,但是效率过慢,不清楚如何优化,使用python测试运行速度很快   PHP 版本 <? php # 只允许输入字符 # 已成功运行 // fwrite(STDOUT,'请输入您的博客名:'); // echo '您输入的信息是:'.fgets(STDIN); // exit(); set_time_limit (0 ); exec ('mode COM3: baud=115200 data=8 stop=1 parity=n xon=on' ); // 打开COM1口 O_RDWR读写模式 O_RDONLY只读 $fd = dio_open('COM3:', O_RDWR); // 打开失败报错 if (! $fd ) { die ("Error when open COM3" ); } // 开始 $ff = dio_stat( $fd ); $len = 8 ; while (1 ){ fwrite (STDOUT,'请设置led灯(h亮l暗): ' ); $line = fgets (STDIN); if ( $line ){ dio_write( $fd , $line ); $data = dio_read(

Arduino编程基础1.1

邮差的信 提交于 2020-05-05 16:54:56
  Arduino编程语言是建立在C/C++语言基础上的,即以C/C++语言为基础,把AVR单片机(微控制器)相关的一些寄存器参数设置等进行函数化,以利于开发者更加快速地使用。其主要使用的函数包括数字I/O引脚操作函数、模拟I/O引脚操作函数、高级I/O引脚操作函数、时间函数、中断函数、串口通信函数和数学函数等。 下面先介绍一些基础规则: 关键字 :if、if...else、for、switch、case、while、do...while、break、continue、return、goto。 语法符号 :每条语句已 “;” 结尾、每段程序用“{}”括起来 数据类型 :boolean、char、int、unsigned int、long、unsigned long、float、double、string、array、void 常量 : HIGH(高电平、1)或LOW(低电平、0),表示数字I/O引脚的电平;     input(表示输入(高阻态))或OUTPUT(表示输出(AVR能提供5V电压,40mA电流)),表示数字I/O引脚的方向;     TRUE(真、1)或者FALSE(假、0) 程序结构 :主要包括两部分,void setup()和void loop().       前者是声明变量及引脚名称,eg:int val; int led=13,在程序开始时使用

工控硬件

时光毁灭记忆、已成空白 提交于 2020-05-05 14:36:30
========================= 通用工控硬件平台: ========================= 1. AVR单片机, AVR 是1997年由ATMEL公司研发出的增强型内置Flash的RISC精简指令集高速 8位 单片机, atmel于2016年被microchip收购了 。可以广泛应用于计算机外部设备、工业实时控制、仪器仪表、通讯设备、家用电器等各个领域。AVR单片机是 Atmel 公司 1997 年推出的 RISC 单片机。 它与51单片机、PIC单片机相比运行效率高很多、芯片内部的Flsah、EEPROM、SRAM容量较大、全部支持在线编程烧写(ISP、每个IO口都可以以推换驱动的方式输出高、低电平,驱动能力强、内部资源丰富,一般都集成AD、DA模数转换器;PWM;SPI、USART、TWI、I2C通信口;丰富的中断源等。主要现在使用的型号是ATMEGA8/16。 AVR和ARM都是精简指令集, 但并不是不同于ARM, 相当于ARM系列里面的M0至M3的能力. http://www.elecfans.com/emb/arm/20171110577994.html 2. ARM Cortex-M系列,Microcontroller主要是应用于工业控制, 很多半导体公司生产基于Cortex-M的 MCU, 下面是两个重要的产品系列. (2.1)