<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Peera Hongwitayakorn on Medium]]></title>
        <description><![CDATA[Stories by Peera Hongwitayakorn on Medium]]></description>
        <link>https://medium.com/@peerahongwitayakorn?source=rss-4cad6d3ffe45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*nFX61d2SeT6ZskdB.</url>
            <title>Stories by Peera Hongwitayakorn on Medium</title>
            <link>https://medium.com/@peerahongwitayakorn?source=rss-4cad6d3ffe45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 11:19:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@peerahongwitayakorn/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[บันทึกการใช้งาน Gravitech Cucumber RS และเรียกข้อมูลความเร่งเชิงมุม และความเร็วเชิงมุม (6DoF)…]]></title>
            <link>https://medium.com/@peerahongwitayakorn/%E0%B8%9A%E0%B8%B1%E0%B8%99%E0%B8%97%E0%B8%B6%E0%B8%81%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-gravitech-cucumber-rs-%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%81%E0%B8%82%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%B9%E0%B8%A5%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B9%80%E0%B8%A3%E0%B9%88%E0%B8%87%E0%B9%80%E0%B8%8A%E0%B8%B4%E0%B8%87%E0%B8%A1%E0%B8%B8%E0%B8%A1-%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B9%80%E0%B8%A3%E0%B9%87%E0%B8%A7%E0%B9%80%E0%B8%8A%E0%B8%B4%E0%B8%87%E0%B8%A1%E0%B8%B8%E0%B8%A1-6dof-93c31076a4c9?source=rss-4cad6d3ffe45------2</link>
            <guid isPermaLink="false">https://medium.com/p/93c31076a4c9</guid>
            <category><![CDATA[gravitech]]></category>
            <category><![CDATA[i2c]]></category>
            <category><![CDATA[esp-idf]]></category>
            <category><![CDATA[cucumberrs]]></category>
            <dc:creator><![CDATA[Peera Hongwitayakorn]]></dc:creator>
            <pubDate>Sun, 17 May 2020 18:28:48 GMT</pubDate>
            <atom:updated>2020-05-17T18:28:48.489Z</atom:updated>
            <content:encoded><![CDATA[<h3>บันทึกการใช้งาน Gravitech Cucumber RS และเรียกข้อมูลความเร่งเชิงมุม และความเร็วเชิงมุม (6DoF) ไปเก็บและ plot กราฟ</h3><p>ผมเป็นคนหนึ่งที่เคยชินกับการเรียกใช้ข้อมูลจาก sensor ต่างๆด้วย library ที่มีคนเผยแพร่ออกมากับ Arduino IDE เป็นหลัก แต่หลังจากคุณแพน แห่งกราวิเทคไทย ได้แนะนำและกรุณาส่งบอร์ด Cucumber RS ที่เป็น ESP32-S2 มาให้ลองเล่นดู ซึ่ง Cucumber เป็นบอร์ด microcontroller ที่ใช้ชิป ESP32-S2 ตัวแรกๆของโลก ดังนั้นจึงต้องหันมาลองใช้ ESP-IDF (Espressif IoT Development Framework) ให้พอเป็นก่อน จะได้ลองใช้งานบอร์ดจากการใช้เครื่องมือที่มาจากผู้ผลิตชิปตัวนี้เอง และจะได้ใช้ features อื่นๆของบอร์ดได้เต็มที่อีกด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uOXXVRliI52eGlJdHgejYQ.jpeg" /><figcaption>Gravitech Cucumber RS</figcaption></figure><p>ข้อมูลของบอร์ดสามารถดูได้จาก web site ของ บ.กราวิเทคไทย ครับ ตาม link นี้เลย <a href="https://www.gravitechthai.com/product-detail.php?WP=rUEjoz1yq3EZoz1iM2A0G2zDrYyj4T1zqlMZG22DM7y04TyjrPMjZT1Cq5OZhJ3tM2E0nJyyrUEjLJ1wq2WZqJ1mMlM0ZTyCrWOjhJ3tq2EZnJ1yM3E0LJywrPMjZT1Cq5OZhJ3tM2E0nJyarPMjBT04qmMZAT1CM5O0hJatrTZo7o3Q">https://www.gravitechthai.com/product-detail.php?WP=rUEjoz1yq3EZoz1iM2A0G2zDrYyj4T1zqlMZG22DM7y04TyjrPMjZT1Cq5OZhJ3tM2E0nJyyrUEjLJ1wq2WZqJ1mMlM0ZTyCrWOjhJ3tq2EZnJ1yM3E0LJywrPMjZT1Cq5OZhJ3tM2E0nJyarPMjBT04qmMZAT1CM5O0hJatrTZo7o3Q</a></p><p>สำหรับบันทึกของผมนี้จะบันทึก Coding ที่ได้ลองใช้ โดยเฉพาะการใช้งาน sensor MPU-6050 ที่เป็น sensor ให้ข้อมูล Accelerometer 3แกนกับ Gyroscope 3แกน ติดมาพร้อมกับบอร์ด ที่ภายในได้ทำการ wire และเชื่อมต่อถึงกันโดยอินเตอร์เฟสแบบ i2c ภายในบอร์ดรุ่น Cucumber RS มาเป็นที่เรียบร้อยแล้ว โดยตั้งใจให้บันทึกทั้ง serie นี้อธิบายการเรียกใช้ข้อมูล 6DoF ดังกล่าว พร้อมกับส่งข้อมูลที่ได้ ไปจัดเก็บใน InfluxDB และสุดท้ายนำข้อมูลเหล่านั้นมาplotให้เห็นเป็นกราฟโดย Grafana</p><p>ในบันทึกส่วนแรกนี้ผมขอแปะ code ส่วนที่เป็นการเชื่อมต่อกับ i2c เพื่อเข้าไป set และอ่านค่า 6DoF และ ค่าอุณหภูมิของตัวชิป MPU-6050 ออกมาเพื่อแสดงผลบนหน้าจอ serial ก่อนครับ ซึ่งหากท่านใดอยากทราบรายละเอียดสามารถทักเข้ามาให้อธิบายเพิ่มได้ครับ และในบันทึกส่วนถัดไปก็จะขอพูดถึงการส่งข้อมูลไปเก็บใน InfluxDB และใช้ Grafana นะครับ</p><p>และในระหว่างที่ผมลองเข้าไปศึกษาการใช้งาน i2c program ของ ESP-IDF และลองไล่เขียนไล่ก๊อป codeแบบงูๆปลาๆ จนได้ code มาตามด้านล่าง ผมได้เห็นบทความที่ดีๆเกี่ยวข้องกับสิ่งที่ผมดูและศึกษาอยู่ โดยผมขออ้างถึง 2 บทความใน medium.com นี้ได้ให้รายละเอียดไว้อย่างมากแล้ว ผมจึงขออนุญาตแนะนำท่านที่ได้แวะมาอ่านบันทึกนี้ หากต้องการความละเอียดเรื่อง sensor MPU-6050 และอื่นๆที่ติดมากับบอร์ด Cucumber RS สามารถเข้าไปอ่านเพิ่มเติมกันได้ตามที่ผมอ้างถึงได้นะครับ</p><p>ผมกันใหม่ในบันทึกส่วนถัดไปครับ</p><p><strong>Coding ::</strong></p><pre><br>/* i2c — Example for Reading MPU6050 on Gravitech Cucumber RS</pre><pre>use and modify code from i2c_example_main.c and cmd_i2ctools.c</pre><pre>datasheet ::</pre><pre>https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf</pre><pre>i2cconfig — — port=0 — freq=400000 — scl=40 — sda=41</pre><pre>i2cset -c 0x68 -r 0x6B 0x00 ; wakeup MPU6050</pre><pre>i2cget -c 0x68 -r 0x3B -l 14 ; read gyrox3 temperature and accelx3 simultaneously</pre><pre>Peera H.</pre><pre>11.05.20</pre><pre>15.05.20</pre><pre>16.05.20</pre><pre>display accelX Y Z — gyroX Y Z — temperature</pre><pre>*/</pre><pre>#include &lt;stdio.h&gt;</pre><pre>#include “driver/i2c.h”</pre><pre>#define PORT_NUMBER I2C_NUM_0 //I2C port number</pre><pre>#define SCL_GPIO 40 //GPIO pin</pre><pre>#define SDA_GPIO 41 //GPIO pin</pre><pre>#define FREQ_HZ 400000 //!&lt; I2C master clock frequency</pre><pre>#define ADDR 0x68 //MPU6050 on Gravitech Cucumber RS</pre><pre>#define WRITE_BIT I2C_MASTER_WRITE</pre><pre>#define READ_BIT I2C_MASTER_READ</pre><pre>#define ACK_CHECK_EN 0x1</pre><pre>#define ACK_CHECK_DIS 0x0</pre><pre>#define ACK_VAL 0x0</pre><pre>#define NACK_VAL 0x1</pre><pre>int chip_addr = 0x68;</pre><pre>int wake_addr = 0x6B;</pre><pre>int data_addr = 0x3B;</pre><pre>void setmpu(void)</pre><pre>{</pre><pre>int len=1;</pre><pre>uint8_t *data = malloc(len);</pre><pre>// — — — CREATE THE I2C PORT — — -</pre><pre>int i2c_master_port = PORT_NUMBER;</pre><pre>i2c_config_t conf;</pre><pre>conf.mode = I2C_MODE_MASTER;</pre><pre>conf.sda_io_num = SDA_GPIO;</pre><pre>conf.sda_pullup_en = GPIO_PULLUP_ENABLE;</pre><pre>conf.scl_io_num = SCL_GPIO;</pre><pre>conf.scl_pullup_en = GPIO_PULLUP_ENABLE;</pre><pre>conf.master.clk_speed = FREQ_HZ;</pre><pre>i2c_param_config(i2c_master_port, &amp;conf);</pre><pre>i2c_driver_install(i2c_master_port, I2C_MODE_MASTER, 0, 0, 0);</pre><pre>i2c_cmd_handle_t cmd = i2c_cmd_link_create();</pre><pre>i2c_master_start(cmd);</pre><pre>i2c_master_write_byte(cmd, chip_addr &lt;&lt; 1 | WRITE_BIT, ACK_CHECK_EN);</pre><pre>i2c_master_write_byte(cmd, wake_addr, ACK_CHECK_EN);</pre><pre>for (int i = 0; i &lt; len; i++) {</pre><pre>i2c_master_write_byte(cmd, 0, ACK_CHECK_EN);</pre><pre>}</pre><pre>i2c_master_stop(cmd);</pre><pre>esp_err_t ret = i2c_master_cmd_begin(i2c_master_port, cmd, 1000 / portTICK_RATE_MS);</pre><pre>i2c_cmd_link_delete(cmd);</pre><pre>if (ret == ESP_OK) {</pre><pre>printf(“Write OK”);</pre><pre>} else if (ret == ESP_ERR_TIMEOUT) {</pre><pre>printf(“Bus is busy”);</pre><pre>} else {</pre><pre>printf(“Write Failed”);</pre><pre>}</pre><pre>free(data);</pre><pre>i2c_driver_delete(i2c_master_port);</pre><pre>}</pre><pre>void readmpu(void)</pre><pre>{</pre><pre>signed short number;</pre><pre>float temperature,accelx,accely,accelz,gyrox,gyroy,gyroz;</pre><pre>int len = 14;</pre><pre>uint8_t *data = malloc(len);</pre><pre>// — — — CREATE THE I2C PORT — — -</pre><pre>int i2c_master_port = PORT_NUMBER;</pre><pre>i2c_config_t conf;</pre><pre>conf.mode = I2C_MODE_MASTER;</pre><pre>conf.sda_io_num = SDA_GPIO;</pre><pre>conf.sda_pullup_en = GPIO_PULLUP_ENABLE;</pre><pre>conf.scl_io_num = SCL_GPIO;</pre><pre>conf.scl_pullup_en = GPIO_PULLUP_ENABLE;</pre><pre>conf.master.clk_speed = FREQ_HZ; //I2C frequency is the clock speed for a complete high low clock sequence</pre><pre>i2c_param_config(i2c_master_port, &amp;conf);</pre><pre>i2c_driver_install(i2c_master_port, conf.mode, 0, 0, 0);</pre><pre>i2c_cmd_handle_t cmd = i2c_cmd_link_create();</pre><pre>i2c_master_start(cmd);</pre><pre>if (data_addr != -1) {</pre><pre>i2c_master_write_byte(cmd, chip_addr &lt;&lt; 1 | WRITE_BIT, ACK_CHECK_EN);</pre><pre>i2c_master_write_byte(cmd, data_addr, ACK_CHECK_EN);</pre><pre>i2c_master_start(cmd);</pre><pre>}</pre><pre>i2c_master_write_byte(cmd, chip_addr &lt;&lt; 1 | READ_BIT, ACK_CHECK_EN);</pre><pre>if (len &gt; 1) {</pre><pre>i2c_master_read(cmd, data, len — 1, ACK_VAL);</pre><pre>}</pre><pre>i2c_master_read_byte(cmd, data + len — 1, NACK_VAL);</pre><pre>i2c_master_stop(cmd);</pre><pre>esp_err_t ret = i2c_master_cmd_begin(i2c_master_port, cmd, 1000 / portTICK_RATE_MS);</pre><pre>i2c_cmd_link_delete(cmd);</pre><pre>if (ret == ESP_OK) {</pre><pre>// for (int i = 0; i &lt; len; i+=2) {</pre><pre>number = data[0] &lt;&lt; 8 | data[1];</pre><pre>accelx = (float) number / 16384;</pre><pre>number = data[2] &lt;&lt; 8 | data[3];</pre><pre>accely = (float) number / 16384;</pre><pre>number = data[4] &lt;&lt; 8 | data[5];</pre><pre>accelz = (float) number / 16384;</pre><pre>number = data[6] &lt;&lt; 8 | data[7];</pre><pre>temperature = ((float) number /340) +36.53;</pre><pre>number = data[8] &lt;&lt; 8 | data[9];</pre><pre>gyrox = (float) number / 131;</pre><pre>number = data[10] &lt;&lt; 8 | data[11];</pre><pre>gyroy = (float) number / 131;</pre><pre>number = data[12] &lt;&lt; 8 | data[13];</pre><pre>gyroz = (float) number / 131;</pre><pre>printf(“%.3f %.3f %.3f — %.3f %.3f %.3f — “, accelx,accely,accelz,gyrox,gyroy,gyroz);</pre><pre>printf(“temp :: %.2f \r\n”,temperature);</pre><pre>// }</pre><pre>} else if (ret == ESP_ERR_TIMEOUT) {</pre><pre>printf(“Bus is busy”);</pre><pre>} else {</pre><pre>printf(“Read failed”);</pre><pre>}</pre><pre>free(data);</pre><pre>i2c_driver_delete(i2c_master_port);</pre><pre>}</pre><pre>void app_main(void)</pre><pre>{</pre><pre>setmpu();</pre><pre>while(1)</pre><pre>{</pre><pre>readmpu();</pre><pre>vTaskDelay(100/portTICK_PERIOD_MS);</pre><pre>}</pre><pre>}</pre><p><strong>Output ::</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*mfy6yyAwZkLvMIu_3DwvpA.png" /><figcaption>output display accelX Y Z — gyroX Y Z — temperature</figcaption></figure><p><strong>อ้างถึง ::</strong></p><p>ขออนุญาตอ้างถึง 2 บทความที่อธิบายรายละเอียดการใช้งาน sensor ของ Gravitech Cucumber RS ไว้เป็นอย่างดีครับ</p><p><a href="https://medium.com/@vsupacha_90388?source=post_page-----bfed08921487----------------------">Vsupacha</a></p><p><a href="https://medium.com/@vsupacha_90388/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99%E0%B9%80%E0%B8%8B%E0%B9%87%E0%B8%99%E0%B9%80%E0%B8%8B%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B8%82%E0%B8%AD%E0%B8%87-cucumber-rs-bfed08921487">การใช้งานเซ็นเซอร์ของ Cucumber RS</a></p><p><a href="https://medium.com/@belltot191?source=post_page-----f721b8a9a53a----------------------">bellmustachecat</a></p><p><a href="https://medium.com/@belltot191/get-started-sensor-onboard-cucumber-ep-3-f721b8a9a53a">Get Started sensor onboard cucumber EP.3</a></p><p>อ้างอิง ::</p><p><a href="https://www.gravitechthai.com/product-detail.php?WP=pQugBUp2GQEgG2rDqYyc4Uuw">https://www.gravitechthai.com/product-detail.php?WP=pQugBUp2GQEgG2rDqYyc4Uuwhttps://www.gravitechthai.com</a></p><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/eaf3ea3e115a40af33c93e3c3b656f0f/href">https://medium.com/media/eaf3ea3e115a40af33c93e3c3b656f0f/href</a></iframe><ul><li><a href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html">Get Started - ESP32 - - ESP-IDF Programming Guide latest documentation</a></li><li><a href="https://awesomeopensource.com/project/natanaeljr/esp32-MPU-driver">Esp32 Mpu Driver</a></li><li><a href="https://github.com/imxieyi/esp32-i2c-mpu6050/blob/master/main/main.cpp">imxieyi/esp32-i2c-mpu6050</a></li></ul><p><strong>ขอขอบคุณ ::</strong></p><p><em>คุณแพน และ Gravitech Thai</em></p><p><em>บทความดีๆ ตามที่อ้างถึง และที่อ้างอิงไว้ครับ</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93c31076a4c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>